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