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 CDMA_SMS_COMMON_H 17 #define CDMA_SMS_COMMON_H 18 19 #include "sms_pdu_code_type.h" 20 21 namespace OHOS { 22 namespace Telephony { 23 static constexpr uint16_t CDMASMS_USER_DATA_LEN_MAX = 160; 24 static constexpr uint16_t CDMASMS_ADDRESS_LEN_MAX = 256; 25 static constexpr uint16_t CDMASMS_NUMBER_OF_ACK_MAX = 8; 26 27 enum class CdmaTransportMsgType : uint8_t { P2P = 0x00, BROADCAST = 0x01, ACK = 0x02, RESERVED }; 28 29 enum class TeleserviceMsgType : uint8_t { 30 RESERVED = 0x00, // reserved 31 DELIVER, // mobile-terminated only 32 SUBMIT, // mobile-originated only 33 CANCEL, // mobile-originated only 34 DELIVERY_ACK, // mobile-terminated only 35 USER_ACK, // either direction 36 READ_ACK, // either direction 37 DELIVER_REPORT, // mobile-originated only 38 SUBMIT_REPORT = 0x08, // mobile-terminated only 39 MAX_VALUE 40 }; 41 42 enum class SmsLanguageType : uint8_t { 43 UNKNOWN, 44 ENGLISH, 45 FRENCH, 46 SPANISH, 47 JAPANESE, 48 KOREAN, 49 CHINESE, 50 HEBREW, 51 }; 52 53 enum class SmsPriorityIndicator : uint8_t { NORMAL = 0x00, INTERACTIVE, URGENT, EMERGENCY, RESERVED }; 54 55 enum class SmsPrivacyIndicator : uint8_t { NOT_RESTRICTED = 0x00, RESTRICTED, CONFIDENTIAL, SECRET }; 56 57 enum class SmsAlertPriority : uint8_t { DEFAULT = 0x00, LOW, MEDIUM, HIGH }; 58 59 enum class SmsDisplayMode : uint8_t { IMMEDIATE = 0x00, DEFAULT_SETTING, USER_INVOKE, RESERVED }; 60 61 enum class SmsEncodingType : uint8_t { 62 OCTET = 0x0, 63 EPM = 0x1, // IS-91 Extended Protocol Message 64 ASCII_7BIT = 0x2, 65 IA5 = 0x3, 66 UNICODE = 0x4, 67 SHIFT_JIS = 0x5, 68 KOREAN = 0x6, 69 LATIN_HEBREW = 0x7, 70 LATIN = 0x8, 71 GSM7BIT = 0x9, 72 GSMDCS = 0xa, 73 EUCKR = 0x10, 74 RESERVED 75 }; 76 77 enum class SmsStatusCode : uint8_t { 78 // ERROR_CLASS = '00' (no error) 79 ACCEPTED = 0x00, 80 DEPOSITED = 0x01, 81 DELIVERED = 0x02, 82 CANCELLED = 0x03, 83 84 // ERROR_CLASS = '10' (temporary condition) 85 TEMP_NETWORK_CONGESTION = 0x84, 86 TEMP_NETWORK_ERROR = 0x85, 87 TEMP_UNKNOWN_ERROR = 0x9F, 88 89 // ERROR_CLASS = '11' (permanent condition) 90 PERMANENT_NETWORK_CONGESTION = 0xC4, 91 PERMANENT_NETWORK_ERROR = 0xC5, 92 PERMANENT_CANCEL_FAILED = 0xC6, 93 PERMANENT_BLOCKED_DESTINATION = 0xC7, 94 PERMANENT_TEXT_TOO_LONG = 0xC8, 95 PERMANENT_DUPLICATE_MESSAGE = 0xC9, 96 PERMANENT_INVALID_DESTINATION = 0xCA, 97 PERMANENT_MESSAGE_EXPIRED = 0xCD, 98 PERMANENT_UNKNOWN_ERROR = 0xDF, 99 }; 100 101 enum class SmsCmaeCategory : uint8_t { 102 GEO = 0x00, 103 MET = 0x01, 104 SAFETY = 0x02, 105 SECURITY = 0x03, 106 RESCUE = 0x04, 107 FIRE = 0x05, 108 HEALTH = 0x06, 109 ENV = 0x07, 110 TRANSPORT = 0x08, 111 INFRA = 0x09, 112 CBRNE = 0x0a, 113 OTHER = 0x0b, 114 RESERVED, 115 }; 116 117 enum class SmsCmaeResponseType : uint8_t { 118 SHELTER = 0x00, 119 EVACUATE = 0x01, 120 PREPARE = 0x02, 121 EXECUTE = 0x03, 122 MONITOR = 0x04, 123 AVOID = 0x05, 124 ASSESS = 0x06, 125 NONE = 0x07, 126 RESERVED, 127 }; 128 129 enum class SmsCmaeSeverity : uint8_t { 130 EXTREME = 0x0, 131 SEVERE = 0x1, 132 RESERVED, 133 }; 134 135 enum class SmsCmaeUrgency : uint8_t { 136 IMMEDIATE = 0x0, 137 EXPECTED = 0x1, 138 RESERVED, 139 }; 140 141 enum class SmsCmaeCertainty : uint8_t { 142 OBSERVED = 0x0, 143 LIKELY = 0x1, 144 RESERVED, 145 }; 146 147 enum class SmsCmaeAlertHandle : uint8_t { 148 PRESIDENTIAL = 0x00, 149 EXTREME = 0x01, 150 SEVERE = 0x02, 151 AMBER = 0x03, 152 RESERVED, 153 }; 154 155 enum class SmsTransTelsvcId : uint16_t { 156 CMT_91 = 0x1000, // IS-91 Extended Protocol Enhanced Services 157 CPT_95 = 0x1001, // Wireless Paging Teleservice 158 CMT_95 = 0x1002, // Wireless Messaging Teleservice 159 VMN_95 = 0x1003, // Voice Mail Notification 160 WAP = 0x1004, // Wireless Application Protocol 161 WEMT = 0x1005, // Wireless Enhanced Messaging Teleservice 162 SCPT = 0x1006, // Service Category Programming Teleservice 163 CATPT = 0x1007, // Card Application Toolkit Protocol Teleservice 164 RESERVED = 0xffff 165 }; 166 167 enum class SmsServiceCtg : uint16_t { 168 UNKNOWN = 0x0000, 169 EMERGENCY = 0x0001, 170 ADMINISTRATIVE = 0x0002, 171 MAINTENANCE = 0x0003, 172 GNEWS_LOCAL = 0x0004, 173 GNEWS_REGIONAL = 0x0005, 174 GNEWS_NATIONAL = 0x0006, 175 GNEWS_INTERNATIONAL = 0x0007, 176 BFNEWS_LOCAL = 0x0008, 177 BFNEWS_REGIONAL = 0x0009, 178 BFNEWS_NATIONAL = 0x000a, 179 BFNEWS_INTERNATIONAL = 0x000b, 180 SNEWS_LOCAL = 0x000c, 181 SNEWS_REGIONAL = 0x000d, 182 SNEWS_NATIONAL = 0x000e, 183 SNEWS_INTERNATIONAL = 0x000f, 184 ENEWS_LOCAL = 0x0010, 185 ENEWS_REGIONAL = 0x0011, 186 ENEWS_NATIONAL = 0x0012, 187 ENEWS_INTERNATIONAL = 0x0013, 188 LOCAL_WEATHER = 0x0014, 189 TRAFFIC_REPORTS = 0x0015, 190 FLIGHT_SCHEDULES = 0x0016, 191 RESTAURANTS = 0x0017, 192 LODGINGS = 0x0018, 193 RETAIL_DIRECTORY = 0x0019, 194 ADVERTISEMENTS = 0x001a, 195 STOCK_QUOTES = 0x001b, 196 EMPLOYMENT = 0x001c, 197 MEDICAL = 0x001d, 198 TECHNOLOGY_NEWS = 0x001e, 199 MULTI_CTG = 0x001f, 200 CATPT = 0x0020, 201 KDDI_CORP_MIN1 = 0x0021, 202 KDDI_CORP_MAX1 = 0x003f, 203 CMAS_PRESIDENTIAL = 0x1000, 204 CMAS_EXTREME = 0x1001, 205 CMAS_SEVERE = 0x1002, 206 CMAS_AMBER = 0x1003, 207 CMAS_TEST = 0x1004, 208 KDDI_CORP_MIN2 = 0x8001, 209 KDDI_CORP_MAX2 = 0x803f, 210 KDDI_CORP_MIN3 = 0xc001, 211 KDDI_CORP_MAX3 = 0xc03f, 212 RESERVED, 213 UNDEFINED = 0x8001, 214 }; 215 216 enum class TransportErrClass { NONE = 0x00, TEMPORARY = 0x02, PERMANENT = 0x03 }; 217 218 enum class TransportCauseCodeType : uint8_t { 219 INVAILD_TELESERVICE_ID = 0x04, 220 SERVICE_TERMINATION_DENIED = 0x62, 221 SMS_TO_FILL_THIS_ENUMS 222 }; 223 224 enum class TransportSubAddrType : uint8_t { NSAP = 0x00, USER = 0x01, RESERVED }; 225 226 enum class SmsNumberType : uint8_t { 227 UNKNOWN = 0x00, 228 INTERNATIONAL = 0x01, 229 NATIONAL = 0x02, 230 NETWORK_SPECIFIC = 0x03, 231 SUBSCRIBER = 0x04, 232 RESERVED_5 = 0x05, 233 ABBREVIATED = 0x06, 234 RESERVED_7 = 0x07, 235 }; 236 237 struct SmsTeleSvcMsgId { 238 uint16_t msgId; 239 bool headerInd; 240 }; 241 242 struct SmsTeleSvcAddr { 243 bool digitMode; 244 uint8_t numberType; 245 uint8_t numberPlan; 246 uint32_t addrLen; 247 char szData[CDMASMS_ADDRESS_LEN_MAX + 1]; 248 }; 249 250 struct SmsReplyOption { 251 bool userAck : 1; 252 bool dak : 1; 253 bool readAck : 1; 254 bool report : 1; 255 }; 256 257 struct SmsValPeriod { 258 uint8_t format; 259 union { 260 SmsTimeRel relTime; 261 SmsTimeAbs absTime; 262 } time; 263 }; 264 265 struct SmsEncodingSpecific { 266 SmsEncodingType encodeType; 267 uint32_t dataLen; 268 char userData[CDMASMS_USER_DATA_LEN_MAX + 1]; 269 }; 270 271 struct SmsTeleSvcUserData { 272 SmsEncodingType encodeType; 273 uint8_t msgType; 274 SmsUDPackage userData; 275 }; 276 277 struct SmsTeleSvcCmasData { 278 uint32_t dataLen; 279 SmsEncodingType encodeType; 280 uint8_t alertText[CDMASMS_USER_DATA_LEN_MAX + 1]; 281 SmsCmaeCategory category; 282 SmsCmaeResponseType responseType; 283 SmsCmaeSeverity severity; 284 SmsCmaeUrgency urgency; 285 SmsCmaeCertainty certainty; 286 uint16_t id; 287 SmsCmaeAlertHandle alertHandle; 288 SmsTimeAbs expires; 289 SmsLanguageType language; 290 bool isWrongRecodeType; 291 }; 292 293 struct SmsEnhancedVmn { 294 SmsPriorityIndicator priority; 295 bool passwordReq; 296 bool setupReq; 297 bool pwChangeReq; 298 uint8_t minPwLen; 299 uint8_t maxPwLen; 300 uint8_t vmNumUnheardMsg; 301 bool vmMailboxAlmFull; 302 bool vmMailboxFull; 303 bool replyAllowed; 304 bool faxIncluded; 305 uint16_t vmLen; 306 uint8_t vmRetDay; 307 uint16_t vmMsgId; 308 uint16_t vmMailboxId; 309 bool anDigitMode; 310 uint8_t anNumberType; 311 uint8_t anNumberPlan; 312 uint8_t anNumField; 313 uint8_t anChar[CDMASMS_USER_DATA_LEN_MAX + 1]; 314 bool cliDigitMode; 315 uint8_t cliNumberType; 316 uint8_t cliNumberPlan; 317 uint8_t cliNumField; 318 uint8_t cliChar[CDMASMS_USER_DATA_LEN_MAX + 1]; 319 }; 320 321 struct SmsEnhancedVmnAck { 322 uint16_t vmMailboxId; 323 uint8_t vmNumUnheardMsg; 324 uint8_t numDeleteAck; 325 uint8_t numPlayAck; 326 uint16_t daVmMsgId[CDMASMS_NUMBER_OF_ACK_MAX + 1]; 327 uint16_t paVmMsgId[CDMASMS_NUMBER_OF_ACK_MAX + 1]; 328 }; 329 330 struct TeleserviceDeliver { 331 SmsTeleSvcMsgId msgId; 332 SmsTeleSvcUserData userData; 333 SmsTeleSvcCmasData cmasData; 334 SmsTimeAbs timeStamp; 335 SmsValPeriod valPeriod; 336 SmsValPeriod deferValPeriod; 337 SmsPriorityIndicator priority; 338 SmsPrivacyIndicator privacy; 339 SmsReplyOption replyOpt; 340 uint32_t numMsg; 341 SmsAlertPriority alertPriority; 342 SmsLanguageType language; 343 SmsTeleSvcAddr callbackNumber; 344 SmsDisplayMode displayMode; 345 SmsEncodingSpecific multiEncodeData; 346 uint16_t depositId; 347 SmsEnhancedVmn vmn; 348 SmsEnhancedVmnAck vmnAck; 349 }; 350 351 struct TeleserviceSubmit { 352 SmsTeleSvcMsgId msgId; 353 SmsTeleSvcUserData userData; 354 SmsValPeriod valPeriod; 355 SmsValPeriod deferValPeriod; 356 SmsPriorityIndicator priority; 357 SmsPrivacyIndicator privacy; 358 SmsReplyOption replyOpt; 359 SmsAlertPriority alertPriority; 360 SmsLanguageType language; 361 SmsTeleSvcAddr callbackNumber; 362 SmsEncodingSpecific multiEncodeData; 363 uint16_t depositId; 364 }; 365 366 struct TeleserviceCancel { 367 SmsTeleSvcMsgId msgId; 368 }; 369 370 struct TeleserviceUserAck { 371 SmsTeleSvcMsgId msgId; 372 SmsTeleSvcUserData userData; 373 uint8_t respCode; 374 SmsTimeAbs timeStamp; 375 SmsEncodingSpecific multiEncodeData; 376 uint16_t depositId; 377 }; 378 379 struct TeleserviceDeliverAck { 380 SmsTeleSvcMsgId msgId; 381 SmsTeleSvcUserData userData; 382 SmsTimeAbs timeStamp; 383 SmsEncodingSpecific multiEncodeData; 384 SmsStatusCode msgStatus; 385 }; 386 387 struct TeleserviceReadAck { 388 SmsTeleSvcMsgId msgId; 389 SmsTeleSvcUserData userData; 390 SmsTimeAbs timeStamp; 391 SmsEncodingSpecific multiEncodeData; 392 uint16_t depositId; 393 }; 394 395 struct TeleserviceDeliverReport { 396 SmsTeleSvcMsgId msgId; 397 uint8_t tpFailCause; 398 SmsTeleSvcUserData userData; 399 SmsLanguageType language; 400 uint8_t multiEncodeData; 401 }; 402 403 struct CdmaTeleserviceMsg { 404 TeleserviceMsgType type; 405 union { 406 TeleserviceDeliver deliver; 407 TeleserviceSubmit submit; 408 TeleserviceCancel cancel; 409 TeleserviceUserAck userAck; 410 TeleserviceDeliverAck deliveryAck; 411 TeleserviceReadAck readAck; 412 TeleserviceDeliverReport report; 413 } data; 414 }; 415 416 struct TransportAddr { 417 bool digitMode; // ture digit 8bit mode, false digit 4bit dtmf 418 bool numberMode; // ture using data network address format, false none data network 419 uint8_t numberType; 420 uint8_t numberPlan; 421 uint32_t addrLen; 422 char szData[CDMASMS_ADDRESS_LEN_MAX + 1]; 423 }; 424 425 struct TransportSubAddr { 426 TransportSubAddrType type; 427 bool odd; 428 uint32_t addrLen; 429 char szData[CDMASMS_ADDRESS_LEN_MAX + 1]; 430 }; 431 432 struct TransportCauseCode { 433 uint8_t transReplySeq; 434 TransportErrClass errorClass; 435 TransportCauseCodeType causeCode; 436 }; 437 438 struct CdmaP2PMsg { 439 uint16_t teleserviceId; 440 uint16_t serviceCtg; 441 TransportAddr address; 442 TransportSubAddr subAddress; 443 uint8_t replySeq; 444 CdmaTeleserviceMsg telesvcMsg; 445 }; 446 447 struct CdmaBroadCastMsg { 448 uint16_t serviceCtg; 449 CdmaTeleserviceMsg telesvcMsg; 450 }; 451 452 struct CdmaAckMsg { 453 TransportAddr address; 454 TransportSubAddr subAddress; 455 TransportCauseCode causeCode; 456 }; 457 458 struct CdmaTransportMsg { 459 CdmaTransportMsgType type; 460 union { 461 CdmaP2PMsg p2p; 462 CdmaBroadCastMsg broadcast; 463 CdmaAckMsg ack; 464 } data; 465 }; 466 467 } // namespace Telephony 468 } // namespace OHOS 469 #endif 470