sms: Headers sort, pdu extract helper
[libsamsung-ipc.git] / include / sms.h
1 /*
2  * This file is part of libsamsung-ipc.
3  *
4  * Copyright (C) 2010-2011 Joerie de Gram <j.de.gram@gmail.com>
5  * Copyright (C) 2011-2014 Paul Kocialkowski <contact@paulk.fr>
6  *
7  * libsamsung-ipc is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 2 of the License, or
10  * (at your option) any later version.
11  *
12  * libsamsung-ipc is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with libsamsung-ipc.  If not, see <http://www.gnu.org/licenses/>.
19  */
20
21 #include <samsung-ipc.h>
22
23 #ifndef __SAMSUNG_IPC_SMS_H__
24 #define __SAMSUNG_IPC_SMS_H__
25
26 /*
27  * Commands
28  */
29
30 #define IPC_SMS_SEND_MSG                                        0x0401
31 #define IPC_SMS_INCOMING_MSG                                    0x0402
32 #define IPC_SMS_READ_MSG                                        0x0403
33 #define IPC_SMS_SAVE_MSG                                        0x0404
34 #define IPC_SMS_DEL_MSG                                         0x0405
35 #define IPC_SMS_DELIVER_REPORT                                  0x0406
36 #define IPC_SMS_DEVICE_READY                                    0x0407
37 #define IPC_SMS_SEL_MEM                                         0x0408
38 #define IPC_SMS_STORED_MSG_COUNT                                0x0409
39 #define IPC_SMS_SVC_CENTER_ADDR                                 0x040A
40 #define IPC_SMS_SVC_OPTION                                      0x040B
41 #define IPC_SMS_MEM_STATUS                                      0x040C
42 #define IPC_SMS_CBS_MSG                                         0x040D
43 #define IPC_SMS_CBS_CFG                                         0x040E
44 #define IPC_SMS_STORED_MSG_STATUS                               0x040F
45 #define IPC_SMS_PARAM_COUNT                                     0x0410
46 #define IPC_SMS_PARAM                                           0x0411
47
48 /*
49  * Values
50  */
51
52 #define IPC_SMS_TYPE_POINT_TO_POINT                             0x01
53 #define IPC_SMS_TYPE_STATUS_REPORT                              0x02
54 #define IPC_SMS_TYPE_OUTGOING                                   0x02
55
56 #define IPC_SMS_MSG_TYPE_MULTIPLE                               0x01
57 #define IPC_SMS_MSG_TYPE_SINGLE                                 0x02
58
59 #define IPC_SMS_ACK_NO_ERROR                                    0x0000
60 #define IPC_SMS_ACK_PDA_FULL_ERROR                              0x8080
61 #define IPC_SMS_ACK_MALFORMED_REQ_ERROR                         0x8061
62 #define IPC_SMS_ACK_UNSPEC_ERROR                                0x806F
63
64 #define IPC_SMS_STATUS_REC_UNREAD                               0x01
65 #define IPC_SMS_STATUS_REC_READ                                 0x02
66 #define IPC_SMS_STATUS_STO_UNSENT                               0x03
67 #define IPC_SMS_STATUS_STO_SENT                                 0x04
68
69 /*
70  * Structures
71  */
72
73 struct ipc_sms_send_msg_request_header {
74     unsigned char type; // IPC_SMS_TYPE
75     unsigned char msg_type; // IPC_SMS_MSG_TYPE
76     unsigned char unknown;
77     unsigned char length;
78 } __attribute__((__packed__));
79
80 struct ipc_sms_send_msg_response_data {
81     unsigned char type; // IPC_SMS_TYPE
82     unsigned short ack; // IPC_SMS_ACK
83     unsigned char id;
84     unsigned char unknown;
85 } __attribute__((__packed__));
86
87 struct ipc_sms_incoming_msg_header {
88     unsigned char msg_type; // IPC_SMS_MSG_TYPE
89     unsigned char type; // IPC_SMS_TYPE
90     unsigned short sim_index;
91     unsigned char id;
92     unsigned char length;
93 } __attribute__((__packed__));
94
95 struct ipc_sms_save_msg_request_data {
96     unsigned char magic;
97     unsigned short index;
98     unsigned char status; // IPC_SMS_STATUS
99     unsigned char length;
100 } __attribute__((__packed__));
101
102 struct ipc_sms_save_msg_response_data {
103     unsigned char magic;
104     unsigned short error;
105     unsigned short index;
106 } __attribute__((__packed__));
107
108 struct ipc_sms_del_msg_request_data {
109     unsigned char magic;
110     unsigned short index;
111 } __attribute__((__packed__));
112
113 struct ipc_sms_del_msg_response_data {
114     unsigned char magic;
115     unsigned short error;
116     unsigned short index;
117 } __attribute__((__packed__));
118
119 struct ipc_sms_deliver_report_request_data {
120     unsigned char type; // IPC_SMS_TYPE
121     unsigned short ack; // IPC_SMS_ACK
122     unsigned char id;
123     unsigned char unknown;
124 } __attribute__((__packed__));
125
126 struct ipc_sms_deliver_report_response_data {
127     unsigned short ack; // IPC_SMS_ACK
128 } __attribute__((__packed__));
129
130 struct ipc_sms_svc_center_addr_header {
131     unsigned char length;
132 } __attribute__((__packed__));
133
134 /*
135  * Helpers
136  */
137
138 void *ipc_sms_send_msg_setup(struct ipc_sms_send_msg_request_header *header,
139     const char *smsc, const char *pdu);
140 char *ipc_sms_incoming_msg_pdu_extract(const void *data, size_t size);
141
142 #endif
143
144 // vim:ts=4:sw=4:expandtab