1 /*
2  * Copyright (C) 2006 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 /*
18  * ISSUES:
19  *
20  */
21 
22 /**
23  * TODO
24  *
25  *
26  */
27 
28 
29 #ifndef ANDROID_RIL_CDMA_SMS_H
30 #define ANDROID_RIL_CDMA_SMS_H 1
31 
32 #include <stdlib.h>
33 
34 #ifdef __cplusplus
35 extern "C" {
36 #endif
37 
38 /* Used by RIL_REQUEST_CDMA_SEND_SMS and RIL_UNSOL_RESPONSE_CDMA_NEW_SMS */
39 
40 #define RIL_CDMA_SMS_ADDRESS_MAX     36
41 #define RIL_CDMA_SMS_SUBADDRESS_MAX  36
42 #define RIL_CDMA_SMS_BEARER_DATA_MAX 255
43 
44 typedef enum {
45     RIL_CDMA_SMS_DIGIT_MODE_4_BIT = 0,     /* DTMF digits */
46     RIL_CDMA_SMS_DIGIT_MODE_8_BIT = 1,
47     RIL_CDMA_SMS_DIGIT_MODE_MAX32 = 0x10000000 /* Force constant ENUM size in structures */
48 } RIL_CDMA_SMS_DigitMode;
49 
50 typedef enum {
51     RIL_CDMA_SMS_NUMBER_MODE_NOT_DATA_NETWORK = 0,
52     RIL_CDMA_SMS_NUMBER_MODE_DATA_NETWORK     = 1,
53     RIL_CDMA_SMS_NUMBER_MODE_MAX32 = 0x10000000 /* Force constant ENUM size in structures */
54 } RIL_CDMA_SMS_NumberMode;
55 
56 typedef enum {
57     RIL_CDMA_SMS_NUMBER_TYPE_UNKNOWN                   = 0,
58     RIL_CDMA_SMS_NUMBER_TYPE_INTERNATIONAL_OR_DATA_IP  = 1,
59       /* INTERNATIONAL is used when number mode is not data network address.
60        * DATA_IP is used when the number mode is data network address
61        */
62     RIL_CDMA_SMS_NUMBER_TYPE_NATIONAL_OR_INTERNET_MAIL = 2,
63       /* NATIONAL is used when the number mode is not data network address.
64        * INTERNET_MAIL is used when the number mode is data network address.
65        * For INTERNET_MAIL, in the address data "digits", each byte contains
66        * an ASCII character. Examples are "[email protected],[email protected] - ref TIA/EIA-637A 3.4.3.3
67        */
68     RIL_CDMA_SMS_NUMBER_TYPE_NETWORK                   = 3,
69     RIL_CDMA_SMS_NUMBER_TYPE_SUBSCRIBER                = 4,
70     RIL_CDMA_SMS_NUMBER_TYPE_ALPHANUMERIC              = 5,
71       /* GSM SMS: address value is GSM 7-bit chars */
72     RIL_CDMA_SMS_NUMBER_TYPE_ABBREVIATED               = 6,
73     RIL_CDMA_SMS_NUMBER_TYPE_RESERVED_7                = 7,
74     RIL_CDMA_SMS_NUMBER_TYPE_MAX32 = 0x10000000 /* Force constant ENUM size in structures */
75 } RIL_CDMA_SMS_NumberType;
76 
77 typedef enum {
78     RIL_CDMA_SMS_NUMBER_PLAN_UNKNOWN     = 0,
79     RIL_CDMA_SMS_NUMBER_PLAN_TELEPHONY   = 1,      /* CCITT E.164 and E.163, including ISDN plan */
80     RIL_CDMA_SMS_NUMBER_PLAN_RESERVED_2  = 2,
81     RIL_CDMA_SMS_NUMBER_PLAN_DATA        = 3,      /* CCITT X.121 */
82     RIL_CDMA_SMS_NUMBER_PLAN_TELEX       = 4,      /* CCITT F.69 */
83     RIL_CDMA_SMS_NUMBER_PLAN_RESERVED_5  = 5,
84     RIL_CDMA_SMS_NUMBER_PLAN_RESERVED_6  = 6,
85     RIL_CDMA_SMS_NUMBER_PLAN_RESERVED_7  = 7,
86     RIL_CDMA_SMS_NUMBER_PLAN_RESERVED_8  = 8,
87     RIL_CDMA_SMS_NUMBER_PLAN_PRIVATE     = 9,
88     RIL_CDMA_SMS_NUMBER_PLAN_RESERVED_10 = 10,
89     RIL_CDMA_SMS_NUMBER_PLAN_RESERVED_11 = 11,
90     RIL_CDMA_SMS_NUMBER_PLAN_RESERVED_12 = 12,
91     RIL_CDMA_SMS_NUMBER_PLAN_RESERVED_13 = 13,
92     RIL_CDMA_SMS_NUMBER_PLAN_RESERVED_14 = 14,
93     RIL_CDMA_SMS_NUMBER_PLAN_RESERVED_15 = 15,
94     RIL_CDMA_SMS_NUMBER_PLAN_MAX32 = 0x10000000 /* Force constant ENUM size in structures */
95 } RIL_CDMA_SMS_NumberPlan;
96 
97 typedef struct {
98     RIL_CDMA_SMS_DigitMode digit_mode;
99       /* Indicates 4-bit or 8-bit */
100     RIL_CDMA_SMS_NumberMode number_mode;
101       /* Used only when digitMode is 8-bit */
102     RIL_CDMA_SMS_NumberType number_type;
103       /* Used only when digitMode is 8-bit.
104        * To specify an international address, use the following:
105        * digitMode = RIL_CDMA_SMS_DIGIT_MODE_8_BIT
106        * numberMode = RIL_CDMA_SMS_NOT_DATA_NETWORK
107        * numberType = RIL_CDMA_SMS_NUMBER_TYPE_INTERNATIONAL_OR_DATA_IP
108        * numberPlan = RIL_CDMA_SMS_NUMBER_PLAN_TELEPHONY
109        * numberOfDigits = number of digits
110        * digits = ASCII digits, e.g. '1', '2', '3'3, '4', and '5'
111        */
112     RIL_CDMA_SMS_NumberPlan number_plan;
113       /* Used only when digitMode is 8-bit */
114     unsigned char number_of_digits;
115     unsigned char digits[ RIL_CDMA_SMS_ADDRESS_MAX ];
116       /* Each byte in this array represnts a 4-bit or 8-bit digit of address data */
117 } RIL_CDMA_SMS_Address;
118 
119 typedef enum {
120     RIL_CDMA_SMS_SUBADDRESS_TYPE_NSAP           = 0,    /* CCITT X.213 or ISO 8348 AD2 */
121     RIL_CDMA_SMS_SUBADDRESS_TYPE_USER_SPECIFIED = 1,    /* e.g. X.25 */
122     RIL_CDMA_SMS_SUBADDRESS_TYPE_MAX32 = 0x10000000 /* Force constant ENUM size in structures */
123 } RIL_CDMA_SMS_SubaddressType;
124 
125 typedef struct {
126     RIL_CDMA_SMS_SubaddressType subaddressType;
127     /* 1 means the last byte's lower 4 bits should be ignored */
128     unsigned char odd;
129     unsigned char number_of_digits;
130     /* Each byte respresents a 8-bit digit of subaddress data */
131     unsigned char digits[ RIL_CDMA_SMS_SUBADDRESS_MAX ];
132 } RIL_CDMA_SMS_Subaddress;
133 
134 typedef struct {
135     int uTeleserviceID;
136     unsigned char bIsServicePresent;
137     int uServicecategory;
138     RIL_CDMA_SMS_Address sAddress;
139     RIL_CDMA_SMS_Subaddress sSubAddress;
140     int uBearerDataLen;
141     unsigned char aBearerData[ RIL_CDMA_SMS_BEARER_DATA_MAX ];
142 } RIL_CDMA_SMS_Message;
143 
144 /* Used by RIL_REQUEST_CDMA_SMS_ACKNOWLEDGE */
145 
146 typedef enum {
147     RIL_CDMA_SMS_NO_ERROR       = 0,
148     RIL_CDMA_SMS_ERROR          = 1,
149     RIL_CDMA_SMS_ERROR_MAX32 = 0x10000000 /* Force constant ENUM size in structures */
150 } RIL_CDMA_SMS_ErrorClass;
151 
152 typedef struct {
153     RIL_CDMA_SMS_ErrorClass uErrorClass;
154     int uSMSCauseCode;  /* As defined in N.S00005, 6.5.2.125.
155                            Currently, only 35 (resource shortage) and
156                            39 (other terminal problem) are reported. */
157 } RIL_CDMA_SMS_Ack;
158 
159 /* Used by RIL_REQUEST_CDMA_SMS_GET_BROADCAST_CONFIG and
160    RIL_REQUEST_CDMA_SMS_SET_BROADCAST_CONFIG */
161 
162 typedef struct {
163     int service_category;
164     int language;
165     unsigned char selected;
166 } RIL_CDMA_BroadcastSmsConfigInfo;
167 
168 /* Used by RIL_REQUEST_CDMA_WRITE_SMS_TO_RUIM */
169 
170 typedef struct {
171     int status;     /* Status of message.  See TS 27.005 3.1, "<stat>": */
172                   /*      0 = "REC UNREAD"    */
173                   /*      1 = "REC READ"      */
174                   /*      2 = "STO UNSENT"    */
175                   /*      3 = "STO SENT"      */
176 
177     RIL_CDMA_SMS_Message message;
178 } RIL_CDMA_SMS_WriteArgs;
179 
180 
181 /* Used by RIL_REQUEST_ENCODE_CDMA_SMS and RIL_REQUEST_DECODE_CDMA_SMS*/
182 
183 #define RIL_CDMA_SMS_UDH_MAX_SND_SIZE           128
184 #define RIL_CDMA_SMS_UDH_EO_DATA_SEGMENT_MAX    131 /* 140 - 3 - 6 */
185 #define RIL_CDMA_SMS_MAX_UD_HEADERS         7
186 #define RIL_CDMA_SMS_USER_DATA_MAX     229
187 #define RIL_CDMA_SMS_ADDRESS_MAX            36
188 #define RIL_CDMA_SMS_UDH_LARGE_PIC_SIZE     128
189 #define RIL_CDMA_SMS_UDH_SMALL_PIC_SIZE     32
190 #define RIL_CDMA_SMS_UDH_VAR_PIC_SIZE       134
191 #define RIL_CDMA_SMS_UDH_ANIM_NUM_BITMAPS   4
192 #define RIL_CDMA_SMS_UDH_LARGE_BITMAP_SIZE  32
193 #define RIL_CDMA_SMS_UDH_SMALL_BITMAP_SIZE  8
194 #define RIL_CDMA_SMS_UDH_OTHER_SIZE         226
195 #define RIL_CDMA_SMS_IP_ADDRESS_SIZE        4
196 
197 /* ------------------- */
198 /* ---- User Data ---- */
199 /* ------------------- */
200 typedef enum {
201     RIL_CDMA_SMS_UDH_CONCAT_8         = 0x00,
202     RIL_CDMA_SMS_UDH_SPECIAL_SM,
203     /* 02 - 03    Reserved */
204     RIL_CDMA_SMS_UDH_PORT_8           = 0x04,
205     RIL_CDMA_SMS_UDH_PORT_16,
206     RIL_CDMA_SMS_UDH_SMSC_CONTROL,
207     RIL_CDMA_SMS_UDH_SOURCE,
208     RIL_CDMA_SMS_UDH_CONCAT_16,
209     RIL_CDMA_SMS_UDH_WCMP,
210     RIL_CDMA_SMS_UDH_TEXT_FORMATING,
211     RIL_CDMA_SMS_UDH_PRE_DEF_SOUND,
212     RIL_CDMA_SMS_UDH_USER_DEF_SOUND,
213     RIL_CDMA_SMS_UDH_PRE_DEF_ANIM,
214     RIL_CDMA_SMS_UDH_LARGE_ANIM,
215     RIL_CDMA_SMS_UDH_SMALL_ANIM,
216     RIL_CDMA_SMS_UDH_LARGE_PICTURE,
217     RIL_CDMA_SMS_UDH_SMALL_PICTURE,
218     RIL_CDMA_SMS_UDH_VAR_PICTURE,
219 
220     RIL_CDMA_SMS_UDH_USER_PROMPT      = 0x13,
221     RIL_CDMA_SMS_UDH_EXTENDED_OBJECT  = 0x14,
222 
223     /* 15 - 1F    Reserved for future EMS */
224 
225     RIL_CDMA_SMS_UDH_RFC822           = 0x20,
226 
227     /*  21 - 6F    Reserved for future use */
228     /*  70 - 7f    Reserved for (U)SIM Toolkit Security Headers */
229     /*  80 - 9F    SME to SME specific use */
230     /*  A0 - BF    Reserved for future use */
231     /*  C0 - DF    SC specific use */
232     /*  E0 - FF    Reserved for future use */
233 
234     RIL_CDMA_SMS_UDH_OTHER            = 0xFFFF, /* For unsupported or proprietary headers */
235     RIL_CDMA_SMS_UDH_ID_MAX32 = 0x10000000   /* Force constant ENUM size in structures */
236 
237 } RIL_CDMA_SMS_UdhId;
238 
239 typedef struct {
240     /*indicates the reference number for a particular concatenated short message. */
241     /*it is constant for every short message which makes up a particular concatenated short message*/
242     unsigned char       msg_ref;
243 
244     /*indicates the total number of short messages within the concatenated short message.
245      The value shall start at 1 and remain constant for every
246      short message which makes up the concatenated short message.
247      if it is 0 then the receiving entity shall ignore the whole Information Element*/
248     unsigned char       total_sm;
249 
250     /*
251      * it indicates the sequence number of a particular short message within the concatenated short
252      * message. The value shall start at 1 and increment by one for every short message sent
253      * within the concatenated short message. If the value is zero or the value is
254      * greater than the value in octet 2 then the receiving
255      * entity shall ignore the whole Information Element.
256      */
257     unsigned char      seq_num;
258 } RIL_CDMA_SMS_UdhConcat8;
259 
260 /* GW message waiting actions
261 */
262 typedef enum {
263     RIL_CDMA_SMS_GW_MSG_WAITING_NONE,
264     RIL_CDMA_SMS_GW_MSG_WAITING_DISCARD,
265     RIL_CDMA_SMS_GW_MSG_WAITING_STORE,
266     RIL_CDMA_SMS_GW_MSG_WAITING_NONE_1111,
267     RIL_CDMA_SMS_GW_MSG_WAITING_MAX32 = 0x10000000 /* Force constant ENUM size in structures */
268 } RIL_CDMA_SMS_GWMsgWaiting;
269 
270 /* GW message waiting types
271 */
272 typedef enum {
273     RIL_CDMA_SMS_GW_MSG_WAITING_VOICEMAIL,
274     RIL_CDMA_SMS_GW_MSG_WAITING_FAX,
275     RIL_CDMA_SMS_GW_MSG_WAITING_EMAIL,
276     RIL_CDMA_SMS_GW_MSG_WAITING_OTHER,
277     RIL_CDMA_SMS_GW_MSG_WAITING_KIND_MAX32 = 0x10000000   /* Force constant ENUM size in structures */
278 } RIL_CDMA_SMS_GWMsgWaitingKind;
279 
280 typedef struct {
281     RIL_CDMA_SMS_GWMsgWaiting                 msg_waiting;
282     RIL_CDMA_SMS_GWMsgWaitingKind             msg_waiting_kind;
283 
284     /*it indicates the number of messages of the type specified in Octet 1 waiting.*/
285     unsigned char                             message_count;
286 } RIL_CDMA_SMS_UdhSpecialSM;
287 
288 typedef struct {
289     unsigned char  dest_port;
290     unsigned char  orig_port;
291 } RIL_CDMA_SMS_UdhWap8;
292 
293 typedef struct {
294     unsigned short  dest_port;
295     unsigned short  orig_port;
296 } RIL_CDMA_SMS_UdhWap16;
297 
298 typedef struct {
299     unsigned short      msg_ref;
300     unsigned char       total_sm;
301     unsigned char       seq_num;
302 
303 } RIL_CDMA_SMS_UdhConcat16;
304 
305 typedef enum {
306     RIL_CDMA_SMS_UDH_LEFT_ALIGNMENT = 0,
307     RIL_CDMA_SMS_UDH_CENTER_ALIGNMENT,
308     RIL_CDMA_SMS_UDH_RIGHT_ALIGNMENT,
309     RIL_CDMA_SMS_UDH_DEFAULT_ALIGNMENT,
310     RIL_CDMA_SMS_UDH_MAX_ALIGNMENT,
311     RIL_CDMA_SMS_UDH_ALIGNMENT_MAX32 = 0x10000000   /* Force constant ENUM size in structures */
312 } RIL_CDMA_SMS_UdhAlignment;
313 
314 typedef enum {
315     RIL_CDMA_SMS_UDH_FONT_NORMAL = 0,
316     RIL_CDMA_SMS_UDH_FONT_LARGE,
317     RIL_CDMA_SMS_UDH_FONT_SMALL,
318     RIL_CDMA_SMS_UDH_FONT_RESERVED,
319     RIL_CDMA_SMS_UDH_FONT_MAX,
320     RIL_CDMA_SMS_UDH_FONT_MAX32 = 0x10000000   /* Force constant ENUM size in structures */
321 } RIL_CDMA_SMS_UdhFontSize;
322 
323 typedef enum {
324     RIL_CDMA_SMS_UDH_TEXT_COLOR_BLACK          = 0x0,
325     RIL_CDMA_SMS_UDH_TEXT_COLOR_DARK_GREY      = 0x1,
326     RIL_CDMA_SMS_UDH_TEXT_COLOR_DARK_RED       = 0x2,
327     RIL_CDMA_SMS_UDH_TEXT_COLOR_DARK_YELLOW    = 0x3,
328     RIL_CDMA_SMS_UDH_TEXT_COLOR_DARK_GREEN     = 0x4,
329     RIL_CDMA_SMS_UDH_TEXT_COLOR_DARK_CYAN      = 0x5,
330     RIL_CDMA_SMS_UDH_TEXT_COLOR_DARK_BLUE      = 0x6,
331     RIL_CDMA_SMS_UDH_TEXT_COLOR_DARK_MAGENTA   = 0x7,
332     RIL_CDMA_SMS_UDH_TEXT_COLOR_GREY           = 0x8,
333     RIL_CDMA_SMS_UDH_TEXT_COLOR_WHITE          = 0x9,
334     RIL_CDMA_SMS_UDH_TEXT_COLOR_BRIGHT_RED     = 0xA,
335     RIL_CDMA_SMS_UDH_TEXT_COLOR_BRIGHT_YELLOW  = 0xB,
336     RIL_CDMA_SMS_UDH_TEXT_COLOR_BRIGHT_GREEN   = 0xC,
337     RIL_CDMA_SMS_UDH_TEXT_COLOR_BRIGHT_CYAN    = 0xD,
338     RIL_CDMA_SMS_UDH_TEXT_COLOR_BRIGHT_BLUE    = 0xE,
339     RIL_CDMA_SMS_UDH_TEXT_COLOR_BRIGHT_MAGENTA = 0xF,
340     RIL_CDMA_SMS_UDH_TEXT_COLOR_MAX32 = 0x10000000   /* Force constant ENUM size in structures */
341 } RIL_CDMA_SMS_UdhTextColor;
342 
343 typedef struct {
344     unsigned char              start_position;
345     unsigned char              text_formatting_length;
346     RIL_CDMA_SMS_UdhAlignment  alignment_type ;       /*bit 0 and  bit 1*/
347     RIL_CDMA_SMS_UdhFontSize   font_size ;            /*bit 3 and  bit 2*/
348     unsigned char              style_bold;            /*bit 4 */
349     unsigned char              style_italic;          /*bit 5  */
350     unsigned char              style_underlined;      /*bit 6 */
351     unsigned char              style_strikethrough;   /*bit 7 */
352 
353     /* if FALSE, ignore the following color information */
354     unsigned char              is_color_present;
355     RIL_CDMA_SMS_UdhTextColor  text_color_foreground;
356     RIL_CDMA_SMS_UdhTextColor  text_color_background;
357 
358 } RIL_CDMA_SMS_UdhTextFormating;
359 
360 /* Predefined sound
361 */
362 typedef struct {
363     unsigned char       position;
364     unsigned char       snd_number;
365 } RIL_CDMA_SMS_UdhPreDefSound;
366 
367 /* User Defined sound
368 */
369 typedef struct {
370     unsigned char       data_length;
371     unsigned char       position;
372     unsigned char       user_def_sound[RIL_CDMA_SMS_UDH_MAX_SND_SIZE];
373 } RIL_CDMA_SMS_UdhUserDefSound;
374 
375 /* Large picture
376 */
377 typedef struct {
378     unsigned char       position;
379     unsigned char       data[RIL_CDMA_SMS_UDH_LARGE_PIC_SIZE];
380 } RIL_CDMA_SMS_UdhLargePictureData;
381 
382 /* Small picture
383 */
384 typedef struct {
385     unsigned char       position;
386     unsigned char       data[RIL_CDMA_SMS_UDH_SMALL_PIC_SIZE];
387 } RIL_CDMA_SMS_UdhSmallPictureData;
388 
389 /* Variable length picture
390 */
391 typedef struct {
392     unsigned char       position;
393     unsigned char       width;    /* Number of pixels - Should be a mutliple of 8 */
394     unsigned char       height;
395     unsigned char       data[RIL_CDMA_SMS_UDH_VAR_PIC_SIZE];
396 } RIL_CDMA_SMS_UdhVarPicture;
397 
398 /* Predefined animation
399 */
400 typedef struct {
401     unsigned char       position;
402     unsigned char       animation_number;
403 } RIL_CDMA_SMS_UdhPreDefAnim;
404 
405 /* Large animation
406 */
407 typedef struct {
408     unsigned char       position;
409     unsigned char       data[RIL_CDMA_SMS_UDH_ANIM_NUM_BITMAPS][RIL_CDMA_SMS_UDH_LARGE_BITMAP_SIZE];
410 } RIL_CDMA_SMS_UdhLargeAnim;
411 
412 /* Small animation
413 */
414 typedef struct {
415     unsigned char       position;
416     unsigned char       data[RIL_CDMA_SMS_UDH_ANIM_NUM_BITMAPS][RIL_CDMA_SMS_UDH_SMALL_BITMAP_SIZE];
417 } RIL_CDMA_SMS_UdhSmallAnim;
418 
419 /* User Prompt Indicator UDH
420 */
421 typedef struct {
422     unsigned char       number_of_objects;
423     /* Number of objects of the same kind that follow this header which will
424     ** be stitched together by the applications. For example, 5 small pictures
425     ** are to be stitched together horizontally, or 6 iMelody tones are to be
426     ** connected together with intermediate iMelody header and footer ignored.
427     ** Allowed objects to be stitched:
428     **   - Images (small, large, variable)
429     **   - User defined sounds
430     */
431 } RIL_CDMA_SMS_UdhUserPrompt;
432 
433 typedef struct {
434     unsigned char         length;
435 
436     unsigned char         data[RIL_CDMA_SMS_UDH_EO_DATA_SEGMENT_MAX];
437     /* RIL_CDMA_SMS_UDH_EO_VCARD: See http://www.imc.org/pdi/vcard-21.doc for payload */
438     /* RIL_CDMA_SMS_UDH_EO_VCALENDAR: See http://www.imc.org/pdi/vcal-10.doc */
439     /* Or: Unsupported/proprietary extended objects */
440 
441 } RIL_CDMA_SMS_UdhEoContent;
442 
443 /* Extended Object UDH
444 */
445 /* Extended Object IDs/types
446 */
447 typedef enum {
448     RIL_CDMA_SMS_UDH_EO_VCARD                   = 0x09,
449     RIL_CDMA_SMS_UDH_EO_VCALENDAR               = 0x0A,
450     RIL_CDMA_SMS_UDH_EO_MAX32 = 0x10000000   /* Force constant ENUM size in structures */
451 } RIL_CDMA_SMS_UdhEoId;
452 
453 typedef struct {
454     /* Extended objects are to be used together with 16-bit concatenation
455     ** UDH. The max number of segments supported for E.O. is 8 at least.
456     */
457     RIL_CDMA_SMS_UdhEoContent    content;
458 
459     unsigned char                                 first_segment;
460     /* The following fields are only present in the first segment of a
461     ** concatenated SMS message.
462     */
463    unsigned char                                   reference;
464     /* Identify those extended object segments which should be linked together
465     */
466    unsigned short                                  length;
467     /* Length of the whole extended object data
468     */
469     unsigned char                                   control;
470     RIL_CDMA_SMS_UdhEoId                    type;
471     unsigned short                                  position;
472     /* Absolute position of the E.O. in the whole text after concatenation,
473     ** starting from 1.
474     */
475 } RIL_CDMA_SMS_UdhEo;
476 
477 typedef struct {
478     RIL_CDMA_SMS_UdhId  header_id;
479     unsigned char               header_length;
480     unsigned char              data[RIL_CDMA_SMS_UDH_OTHER_SIZE];
481 } RIL_CDMA_SMS_UdhOther;
482 
483 typedef struct {
484     unsigned char        header_length;
485 } RIL_CDMA_SMS_UdhRfc822;
486 
487 typedef struct {
488     RIL_CDMA_SMS_UdhId                header_id;
489 
490     union {
491         RIL_CDMA_SMS_UdhConcat8             concat_8;       // 00
492 
493         RIL_CDMA_SMS_UdhSpecialSM           special_sm;     // 01
494         RIL_CDMA_SMS_UdhWap8                wap_8;          // 04
495         RIL_CDMA_SMS_UdhWap16               wap_16;         // 05
496         RIL_CDMA_SMS_UdhConcat16            concat_16;      // 08
497         RIL_CDMA_SMS_UdhTextFormating       text_formating; // 0a
498         RIL_CDMA_SMS_UdhPreDefSound         pre_def_sound;  // 0b
499         RIL_CDMA_SMS_UdhUserDefSound        user_def_sound; // 0c
500         RIL_CDMA_SMS_UdhPreDefAnim          pre_def_anim;   // 0d
501         RIL_CDMA_SMS_UdhLargeAnim           large_anim;     // 0e
502         RIL_CDMA_SMS_UdhSmallAnim           small_anim;     // 0f
503         RIL_CDMA_SMS_UdhLargePictureData    large_picture;  // 10
504         RIL_CDMA_SMS_UdhSmallPictureData    small_picture;  // 11
505         RIL_CDMA_SMS_UdhVarPicture          var_picture;    // 12
506 
507         RIL_CDMA_SMS_UdhUserPrompt          user_prompt;    // 13
508         RIL_CDMA_SMS_UdhEo                  eo;             // 14
509 
510         RIL_CDMA_SMS_UdhRfc822              rfc822;         // 20
511         RIL_CDMA_SMS_UdhOther               other;
512 
513     }u;
514 } RIL_CDMA_SMS_Udh;
515 
516 /* ----------------------------- */
517 /* -- User data encoding type -- */
518 /* ----------------------------- */
519 typedef enum {
520     RIL_CDMA_SMS_ENCODING_OCTET        = 0,    /* 8-bit */
521     RIL_CDMA_SMS_ENCODING_IS91EP,              /* varies */
522     RIL_CDMA_SMS_ENCODING_ASCII,               /* 7-bit */
523     RIL_CDMA_SMS_ENCODING_IA5,                 /* 7-bit */
524     RIL_CDMA_SMS_ENCODING_UNICODE,             /* 16-bit */
525     RIL_CDMA_SMS_ENCODING_SHIFT_JIS,           /* 8 or 16-bit */
526     RIL_CDMA_SMS_ENCODING_KOREAN,              /* 8 or 16-bit */
527     RIL_CDMA_SMS_ENCODING_LATIN_HEBREW,        /* 8-bit */
528     RIL_CDMA_SMS_ENCODING_LATIN,               /* 8-bit */
529     RIL_CDMA_SMS_ENCODING_GSM_7_BIT_DEFAULT,   /* 7-bit */
530     RIL_CDMA_SMS_ENCODING_MAX32        = 0x10000000
531 
532 } RIL_CDMA_SMS_UserDataEncoding;
533 
534 /* ------------------------ */
535 /* -- IS-91 EP data type -- */
536 /* ------------------------ */
537 typedef enum {
538     RIL_CDMA_SMS_IS91EP_VOICE_MAIL         = 0x82,
539     RIL_CDMA_SMS_IS91EP_SHORT_MESSAGE_FULL = 0x83,
540     RIL_CDMA_SMS_IS91EP_CLI_ORDER          = 0x84,
541     RIL_CDMA_SMS_IS91EP_SHORT_MESSAGE      = 0x85,
542     RIL_CDMA_SMS_IS91EP_MAX32              = 0x10000000
543 
544 } RIL_CDMA_SMS_IS91EPType;
545 
546 typedef struct {
547     /* NOTE: If message_id.udh_present == TRUE:
548     **       'num_headers' is the number of User Data Headers (UDHs),
549     **       and 'headers' include all those headers.
550     */
551     unsigned char                              num_headers;
552     RIL_CDMA_SMS_Udh                     headers[RIL_CDMA_SMS_MAX_UD_HEADERS];
553 
554     RIL_CDMA_SMS_UserDataEncoding      encoding;
555     RIL_CDMA_SMS_IS91EPType             is91ep_type;
556 
557     /*----------------------------------------------------------------------
558      'data_len' indicates the valid number of bytes in the 'data' array.
559 
560      'padding_bits' (0-7) indicates how many bits in the last byte of 'data'
561      are invalid bits. This parameter is only used for Mobile-Originated
562      messages. There is no way for the API to tell how many padding bits
563      exist in the received message. Instead, the application can find out how
564      many padding bits exist in the user data when decoding the user data.
565 
566      'data' has the raw bits of the user data field of the SMS message.
567      The client software should decode the raw user data according to its
568      supported encoding types and languages.
569 
570      EXCEPTION 1: CMT-91 user data raw bits are first translated into BD fields
571      (e.g. num_messages, callback, etc.) The translated user data field in
572      VMN and Short Message is in the form of ASCII characters, each occupying
573      a byte in the resulted 'data'.
574 
575      EXCEPTION 2: GSM 7-bit Default characters are decoded so that each byte
576      has one 7-bit GSM character.
577 
578      'number_of_digits' is the number of digits/characters (7, 8, 16, or
579      whatever bits) in the raw user data, which can be used by the client
580      when decoding the user data according to the encoding type and language.
581     -------------------------------------------------------------------------*/
582     unsigned char                                data_len;
583     unsigned char                                padding_bits;
584     unsigned char                                data[ RIL_CDMA_SMS_USER_DATA_MAX ];
585     unsigned char                                number_of_digits;
586 
587 } RIL_CDMA_SMS_CdmaUserData;
588 
589 /* -------------------- */
590 /* ---- Message Id ---- */
591 /* -------------------- */
592 typedef enum {
593     RIL_CDMA_SMS_BD_TYPE_RESERVED_0     = 0,
594     RIL_CDMA_SMS_BD_TYPE_DELIVER,       /* MT only */
595     RIL_CDMA_SMS_BD_TYPE_SUBMIT,        /* MO only */
596     RIL_CDMA_SMS_BD_TYPE_CANCELLATION,  /* MO only */
597     RIL_CDMA_SMS_BD_TYPE_DELIVERY_ACK,  /* MT only */
598     RIL_CDMA_SMS_BD_TYPE_USER_ACK,      /* MT & MO */
599     RIL_CDMA_SMS_BD_TYPE_READ_ACK,      /* MT & MO */
600     RIL_CDMA_SMS_BD_TYPE_MAX32          = 0x10000000
601 
602 } RIL_CDMA_SMS_BdMessageType;
603 
604 typedef unsigned int  RIL_CDMA_SMS_MessageNumber;
605 
606 typedef struct {
607     RIL_CDMA_SMS_BdMessageType   type;
608     RIL_CDMA_SMS_MessageNumber      id_number;
609     unsigned char                      udh_present;
610     /* NOTE: if FEATURE_SMS_UDH is not defined,
611     ** udh_present should be ignored.
612     */
613 } RIL_CDMA_SMS_MessageId;
614 
615 typedef unsigned char           RIL_CDMA_SMS_UserResponse;
616 
617 /* ------------------- */
618 /* ---- Timestamp ---- */
619 /* ------------------- */
620 typedef struct {
621     /* If 'year' is between 96 and 99, the actual year is 1900 + 'year';
622        if 'year' is between 00 and 95, the actual year is 2000 + 'year'.
623        NOTE: Each field has two BCD digits and byte arrangement is <MSB, ... ,LSB>
624     */
625     unsigned char      year;        /* 0x00-0x99 */
626     unsigned char      month;       /* 0x01-0x12 */
627     unsigned char      day;         /* 0x01-0x31 */
628     unsigned char      hour;        /* 0x00-0x23 */
629     unsigned char      minute;      /* 0x00-0x59 */
630     unsigned char      second;      /* 0x00-0x59 */
631     signed char      timezone;    /* +/-, [-48,+48] number of 15 minutes - GW only */
632 } RIL_CDMA_SMS_Timestamp;
633 
634 /* ------------------ */
635 /* ---- Priority ---- */
636 /* ------------------ */
637 typedef enum {
638     RIL_CDMA_SMS_PRIORITY_NORMAL      = 0,
639     RIL_CDMA_SMS_PRIORITY_INTERACTIVE,
640     RIL_CDMA_SMS_PRIORITY_URGENT,
641     RIL_CDMA_SMS_PRIORITY_EMERGENCY,
642     RIL_CDMA_SMS_PRIORITY_MAX32       = 0x10000000
643 
644 } RIL_CDMA_SMS_Priority;
645 
646 /* ----------------- */
647 /* ---- Privacy ---- */
648 /* ----------------- */
649 typedef enum {
650     RIL_CDMA_SMS_PRIVACY_NORMAL      = 0,
651     RIL_CDMA_SMS_PRIVACY_RESTRICTED,
652     RIL_CDMA_SMS_PRIVACY_CONFIDENTIAL,
653     RIL_CDMA_SMS_PRIVACY_SECRET,
654     RIL_CDMA_SMS_PRIVACY_MAX32       = 0x10000000
655 
656 } RIL_CDMA_SMS_Privacy;
657 
658 /* ---------------------- */
659 /* ---- Reply option ---- */
660 /* ---------------------- */
661 typedef struct {
662     /* whether user ack is requested
663     */
664     unsigned char          user_ack_requested;
665 
666     /* whether delivery ack is requested.
667        Should be FALSE for incoming messages.
668     */
669     unsigned char          delivery_ack_requested;
670 
671     /* Message originator requests the receiving phone to send back a READ_ACK
672     ** message automatically when the user reads the received message.
673     */
674     unsigned char          read_ack_requested;
675 
676 } RIL_CDMA_SMS_ReplyOption;
677 
678 typedef enum {
679     RIL_CDMA_SMS_ALERT_MODE_DEFAULT         = 0,
680     RIL_CDMA_SMS_ALERT_MODE_LOW_PRIORITY    = 1,
681     RIL_CDMA_SMS_ALERT_MODE_MEDIUM_PRIORITY = 2,
682     RIL_CDMA_SMS_ALERT_MODE_HIGH_PRIORITY   = 3,
683 
684     /* For pre-IS637A implementations, alert_mode only has values of True/False:
685     */
686     RIL_CDMA_SMS_ALERT_MODE_OFF   = 0,
687     RIL_CDMA_SMS_ALERT_MODE_ON    = 1
688 
689 } RIL_CDMA_SMS_AlertMode;
690 
691 /* ------------------ */
692 /* ---- Language ---- */
693 /* ------------------ */
694 typedef enum {
695     RIL_CDMA_SMS_LANGUAGE_UNSPECIFIED = 0,
696     RIL_CDMA_SMS_LANGUAGE_ENGLISH,
697     RIL_CDMA_SMS_LANGUAGE_FRENCH,
698     RIL_CDMA_SMS_LANGUAGE_SPANISH,
699     RIL_CDMA_SMS_LANGUAGE_JAPANESE,
700     RIL_CDMA_SMS_LANGUAGE_KOREAN,
701     RIL_CDMA_SMS_LANGUAGE_CHINESE,
702     RIL_CDMA_SMS_LANGUAGE_HEBREW,
703     RIL_CDMA_SMS_LANGUAGE_MAX32       = 0x10000000
704 
705 } RIL_CDMA_SMS_Language;
706 
707 /* ---------------------------------- */
708 /* ---------- Display Mode ---------- */
709 /* ---------------------------------- */
710 typedef enum {
711     RIL_CDMA_SMS_DISPLAY_MODE_IMMEDIATE   = 0,
712     RIL_CDMA_SMS_DISPLAY_MODE_DEFAULT     = 1,
713     RIL_CDMA_SMS_DISPLAY_MODE_USER_INVOKE = 2,
714     RIL_CDMA_SMS_DISPLAY_MODE_RESERVED    = 3
715 } RIL_CDMA_SMS_DisplayMode;
716 
717 /* IS-637B parameters/fields
718 */
719 
720 /* ---------------------------------- */
721 /* ---------- Delivery Status ------- */
722 /* ---------------------------------- */
723 typedef enum {
724     RIL_CDMA_SMS_DELIVERY_STATUS_ACCEPTED              = 0,    /* ERROR_CLASS_NONE */
725     RIL_CDMA_SMS_DELIVERY_STATUS_DEPOSITED_TO_INTERNET = 1,    /* ERROR_CLASS_NONE */
726     RIL_CDMA_SMS_DELIVERY_STATUS_DELIVERED             = 2,    /* ERROR_CLASS_NONE */
727     RIL_CDMA_SMS_DELIVERY_STATUS_CANCELLED             = 3,    /* ERROR_CLASS_NONE */
728 
729     RIL_CDMA_SMS_DELIVERY_STATUS_NETWORK_CONGESTION  = 4,    /* ERROR_CLASS_TEMP & PERM */
730     RIL_CDMA_SMS_DELIVERY_STATUS_NETWORK_ERROR       = 5,    /* ERROR_CLASS_TEMP & PERM */
731     RIL_CDMA_SMS_DELIVERY_STATUS_CANCEL_FAILED       = 6,    /* ERROR_CLASS_PERM */
732     RIL_CDMA_SMS_DELIVERY_STATUS_BLOCKED_DESTINATION = 7,    /* ERROR_CLASS_PERM */
733     RIL_CDMA_SMS_DELIVERY_STATUS_TEXT_TOO_LONG       = 8,    /* ERROR_CLASS_PERM */
734     RIL_CDMA_SMS_DELIVERY_STATUS_DUPLICATE_MESSAGE   = 9,    /* ERROR_CLASS_PERM */
735     RIL_CDMA_SMS_DELIVERY_STATUS_INVALID_DESTINATION = 10,   /* ERROR_CLASS_PERM */
736     RIL_CDMA_SMS_DELIVERY_STATUS_MESSAGE_EXPIRED     = 13,   /* ERROR_CLASS_PERM */
737 
738     RIL_CDMA_SMS_DELIVERY_STATUS_UNKNOWN_ERROR       = 0x1F  /* ERROR_CLASS_PERM */
739 
740     /* All the other values are reserved */
741 
742 } RIL_CDMA_SMS_DeliveryStatusE;
743 
744 typedef struct {
745     RIL_CDMA_SMS_ErrorClass       error_class;
746     RIL_CDMA_SMS_DeliveryStatusE   status;
747 } RIL_CDMA_SMS_DeliveryStatus;
748 
749 typedef struct {
750     unsigned char               address[RIL_CDMA_SMS_IP_ADDRESS_SIZE];
751     unsigned char             is_valid;
752 } RIL_CDMA_SMS_IpAddress;
753 
754 /* This special parameter captures any unrecognized/proprietary parameters
755 */
756 typedef struct {
757     unsigned char                         input_other_len;
758     unsigned char                         desired_other_len; /* used during decoding */
759     unsigned char                         * other_data;
760 } RIL_CDMA_SMS_OtherParm;
761 
762 typedef struct {
763     /* the mask indicates which fields are present in this message */
764     unsigned int                        mask;
765 
766     RIL_CDMA_SMS_MessageId         message_id;
767     RIL_CDMA_SMS_CdmaUserData     user_data;
768     RIL_CDMA_SMS_UserResponse        user_response;
769     RIL_CDMA_SMS_Timestamp          mc_time;
770     RIL_CDMA_SMS_Timestamp          validity_absolute;
771     RIL_CDMA_SMS_Timestamp          validity_relative;
772     RIL_CDMA_SMS_Timestamp          deferred_absolute;
773     RIL_CDMA_SMS_Timestamp          deferred_relative;
774     RIL_CDMA_SMS_Priority           priority;
775     RIL_CDMA_SMS_Privacy            privacy;
776     RIL_CDMA_SMS_ReplyOption       reply_option;
777     unsigned char                         num_messages;  /* the actual value; not BCDs */
778     RIL_CDMA_SMS_AlertMode         alert_mode;
779      /* For pre-IS-637A implementations, alert_mode is either Off or On. */
780     RIL_CDMA_SMS_Language           language;
781     RIL_CDMA_SMS_Address            callback;
782     RIL_CDMA_SMS_DisplayMode       display_mode;
783 
784     RIL_CDMA_SMS_DeliveryStatus    delivery_status;
785     unsigned int                        deposit_index;
786 
787     RIL_CDMA_SMS_IpAddress         ip_address;
788     unsigned char                         rsn_no_notify;
789 
790     /* See function comments of wms_ts_decode() and
791     ** wms_ts_decode_cdma_bd_with_other() for details regarding 'other' parameters
792     */
793     RIL_CDMA_SMS_OtherParm         other;
794 
795 } RIL_CDMA_SMS_ClientBd;
796 
797 typedef struct {
798     unsigned char length;   /* length, in bytes, of the encoded SMS message */
799     unsigned char * data;   /* the encoded SMS message (max 255 bytes) */
800 } RIL_CDMA_Encoded_SMS;
801 
802 #ifdef __cplusplus
803 }
804 #endif
805 
806 #endif /*ANDROID_RIL_CDMA_SMS_H*/
807