1 /*
2  * Copyright (C) 2021 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 OHOS_RIL_VENDOR_SMS_DEFS_H
17 #define OHOS_RIL_VENDOR_SMS_DEFS_H
18 
19 #include "hril_enum.h"
20 #include "hril_public_struct.h"
21 
22 #ifdef __cplusplus
23 extern "C" {
24 #endif
25 
26 /**
27  * @brief Defines the SMS response.
28  */
29 typedef struct {
30     /**
31      * TP-Message-Reference for GSM, and BearerData MessageId for CDMA
32      * from 3GPP2 C.S0015-B, v2.0, 4.5-1
33      */
34     int32_t msgRef;
35     /**
36       *Protocol Data Unit
37       */
38     char *pdu;
39     /**
40      * if unknown or not applicable, that is -1
41      * from 3GPP 27.005, 3.2.5 for GSM/UMTS,
42      * 3GPP2 N.S0005 (IS-41C) Table 171 for CDMA
43      */
44     int32_t errCode;
45 } HRilSmsResponse;
46 
47 /**
48  * @brief Defines the SMS message information in a SIM card.
49  */
50 typedef struct {
51     /**
52      * Number index
53      */
54     int32_t index;
55     /**
56      * Status
57      */
58     int32_t state;
59     /**
60      * Short message service center
61      */
62     char *smsc;
63     /**
64      * Protocol Data Unit
65      */
66     char *pdu;
67 } HRilSmsWriteSms;
68 
69 /**
70  * @brief Defines the SMSC address information.
71  */
72 typedef struct {
73     /**
74      * SMSC address type. For details, see 3GPP TS 24.011 [6].
75      */
76     int32_t tosca;
77     /**
78      * SMSC address. For details, see 3GPP TS 24.011 [6].
79      */
80     char *address;
81 } HRilServiceCenterAddress;
82 
83 /**
84  * @brief Defines the GSM cell broadcast configuration information.
85  *
86  */
87 typedef struct {
88     /**
89      * Message start ID
90      */
91     int32_t startOfServiceId;
92     /**
93      * Message end ID
94      */
95     int32_t endOfServiceId;
96     /**
97      * Data start coding scheme
98      */
99     int32_t startOfCodeScheme;
100     /**
101      * Data end coding scheme
102      */
103     int32_t endOfCodeScheme;
104     /**
105      * selected (activated or not)
106      */
107     unsigned char selected;
108 } HRilCBConfigInfo;
109 
110 /**
111  * @brief Defines the CDMA cell broadcast configuration information.
112  */
113 typedef struct {
114     /**
115      * Service
116      */
117     int32_t service;
118     /**
119      * Language
120      */
121     int32_t language;
122     /**
123      * Selected or not
124      */
125     unsigned char checked;
126 } HRilCdmaCBConfigInfo;
127 
128 /**
129  * @brief Defines the cell broadcast report information.
130  *
131  * From 3GPP TS 27.005   if text mode (+CMGF=1):
132  * <CR><LF>+CBM:
133  * <sn>,<mid>,<dcs>,<page>,<pages><CR><LF><data><CR>
134  * <LF> if PDU mode
135  * (+CMGF=0):
136  * <CR><LF>+CBM: <length><CR><LF><pdu><CR><LF>
137  */
138 typedef struct {
139     /**
140      * Cell broadcast SN
141      */
142     int32_t sn;
143     /**
144      * Message IDs
145      */
146     int32_t mid;
147     /**
148      * Cell broadcast page number
149      */
150     int32_t page;
151     /**
152      * Total number of cell broadcast pages
153      */
154     int32_t pages;
155     /**
156      * Data coding schemes
157      */
158     char *dcs;
159     /**
160      * Decoded cell broadcast content
161      */
162     char *data;
163     /**
164      * Number of PDU bytes
165      */
166     int32_t length;
167     /**
168      * Protocol data unit
169      */
170     char *pdu;
171 } HRilCBConfigReportInfo;
172 
173 typedef struct {
174     int32_t digitMode;
175     int32_t mode;
176     int32_t type;
177     int32_t plan;
178     unsigned char number;
179     unsigned char bytes[HRIL_MAX_CDMA_ADDRESS_LEN];
180 } HRilCdmaSmsAddress;
181 
182 typedef struct {
183     int32_t type;
184     unsigned char odd;
185     unsigned char number;
186     unsigned char bytes[HRIL_MAX_CDMA_ADDRESS_LEN];
187 } HRilCdmaSmsSubAddress;
188 
189 typedef struct {
190     int32_t serviceId;
191     unsigned char isExist;
192     int32_t type;
193     HRilCdmaSmsAddress address;
194     HRilCdmaSmsSubAddress subAddress;
195     int32_t size;
196     unsigned char bytes[HRIL_MAX_CDMA_MESSAGE_LEN];
197 } HRilCdmaSmsMessageInfo;
198 
199 /**
200  * @brief Defines the CDMA SMS message information in a SIM card.
201  */
202 typedef struct {
203     /**
204      * Status. For details, see TS 27.005 3.1
205      */
206     int32_t state;
207     /**
208      * CDMA message infomation.
209      */
210     HRilCdmaSmsMessageInfo cdmaMessageInfo;
211 } HRilSmsWriteCdmaSms;
212 
213 typedef struct {
214     void (*SendGsmSms)(const ReqDataInfo *requestInfo, const char *const *data, size_t dataLen);
215     void (*SendSmsAck)(const ReqDataInfo *requestInfo, const int32_t *data, size_t dataLen);
216     void (*SendCdmaSms)(const ReqDataInfo *requestInfo, const char *data, size_t dataLen);
217     void (*SendCdmaAck)(const ReqDataInfo *requestInfo, const char *data, size_t dataLen);
218     void (*AddSimMessage)(const ReqDataInfo *requestInfo, const HRilSmsWriteSms *data, size_t dataLen);
219     void (*DelSimMessage)(const ReqDataInfo *requestInfo, const int32_t *data, size_t dataLen);
220     void (*UpdateSimMessage)(const ReqDataInfo *requestInfo, const HRilSmsWriteSms *data, size_t dataLen);
221     void (*SetSmscAddr)(const ReqDataInfo *requestInfo, const HRilServiceCenterAddress *data, size_t dataLen);
222     void (*GetSmscAddr)(const ReqDataInfo *requestInfo);
223     void (*SetCBConfig)(const ReqDataInfo *requestInfo, const HRilCBConfigInfo *data, size_t dataLen);
224     void (*GetCBConfig)(const ReqDataInfo *requestInfo);
225     void (*GetCdmaCBConfig)(const ReqDataInfo *requestInfo);
226     void (*SetCdmaCBConfig)(const ReqDataInfo *requestInfo, const HRilCdmaCBConfigInfo *data, size_t dataLen);
227     void (*AddCdmaSimMessage)(const ReqDataInfo *requestInfo, const HRilSmsWriteSms *data, size_t dataLen);
228     void (*AddCdmaSimMessageV2)(const ReqDataInfo *requestInfo, const HRilSmsWriteCdmaSms *data, size_t dataLen);
229     void (*DelCdmaSimMessage)(const ReqDataInfo *requestInfo, const int32_t *data, size_t dataLen);
230     void (*UpdateCdmaSimMessage)(const ReqDataInfo *requestInfo, const HRilSmsWriteSms *data, size_t dataLen);
231     /**
232      * @brief Set whether memory is available for new SMS messages.
233      *
234      * @param requestInfo Request data info, for details, see {@link
235      * ReqDataInfo}.
236      * @param available Whether memory is available, 0 indicates memory is not available,
237      * 1 indicates available otherwise.
238      * @see ReqDataInfo
239      */
240     void (*SetSmsMemoryStatus)(const ReqDataInfo *requestInfo, int32_t available);
241 } HRilSmsReq;
242 #ifdef __cplusplus
243 }
244 #endif
245 #endif // OHOS_RIL_VENDOR_SMS_DEFS_H
246