summaryrefslogtreecommitdiffstats
path: root/tinySMS/include/tinysms/rpdu/tsms_rpdu.h
blob: 274ee9a4e6c5f61864b9c8131826ffc2280b0885 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
/*
* Copyright (C) 2009 Mamadou Diop.
*
* Contact: Mamadou Diop <diopmamadou(at)doubango.org>
*	
* This file is part of Open Source Doubango Framework.
*
* DOUBANGO is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*	
* DOUBANGO is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU General Public License for more details.
*	
* You should have received a copy of the GNU General Public License
* along with DOUBANGO.
*
*/

/**@file tsms_rpdu.h
 * @brief SMS RPDU encoder/decoder as per 3GPP TS 23.011.
 *
 * @author Mamadou Diop <diopmamadou(at)doubango.org>
 *
 * @date Created: Sat Nov 8 16:54:58 2009 mdiop
 */
#ifndef TINYSMS_TSMS_RPDU_H
#define TINYSMS_TSMS_RPDU_H

#include "tinysms_config.h"

#include "tinysms/tsms_common.h"

TSMS_BEGIN_DECLS

/** @a RP-DATA as per 3GPP TS 24.011 section 7.3.1. */
typedef struct tsms_rpdu_data_s
{
	TSMS_DECLARE_RPDU_MESSAGE;

	// section 8.2.5.1
	tsms_address_t *oa;
	//section 8.2.5.2
	tsms_address_t *da;
	// section 8.2.5.3
	tsk_buffer_t* udata;
}
tsms_rpdu_data_t;

/** cast any pointer to @ref tsms_rpdu_data_t* */
#define TSMS_RPDU_DATA(self) ((tsms_rpdu_data_t*)(self))

TINYSMS_API tsms_rpdu_data_t* tsms_rpdu_data_create(uint8_t mr, const tsms_address_string_t smsc, const tsms_tpdu_message_t* tpdu, tsk_bool_t MobOrig);

/**@ingroup tsms_rpdu_group
* @def tsms_rpdu_data_create_mo
* Creates a Mobile Originated @a RP-DATA message.
* @a RP-DATA messages are use to relay the TPDUs.
* For more information, please refer to 3GPP TS 24.011 section 7.3.1.
* @param mr @a RP-Message Reference as per 3GPP TS 24.011 section 8.2.3.
* @param smsc The address of the SMSC. e.g. "+331253688".
* @param tpdu A Pointer to the @a TP-Message to relay.
* @retval Mobile Originated @a RP-DATA message.
* @sa @ref tsms_rpdu_data_create_mt<br>@ref tsms_rpdu_data_create
*
* See For more information, see @ref tsms_rpdu_group_DATA "RP-DATA".
*/
/**@ingroup tsms_rpdu_group
* @def tsms_rpdu_data_create_mt
* Creates a Mobile Terminated @a RP-DATA message.
* @a RP-DATA messages are use to relay the TPDUs.
* For more information, please refer to 3GPP TS 24.011 section 7.3.1.
* @param mr RP-Message Reference as per 3GPP TS 24.011 section 8.2.3.
* @param smsc The address of the SMSC. e.g. "+331253688".
* @param tpdu A Pointer to the @a TP-Message to relay.
* @retval Mobile Terminated RP-DATA message.
* @sa @ref tsms_rpdu_data_create_mo<br>@ref tsms_rpdu_data_create
*
* See For more information, see @ref tsms_rpdu_group_DATA "RP-DATA".
*/
/**@ingroup tsms_rpdu_group
* @def tsms_rpdu_data_serialize
* Serialize a @a RP-DATA message as binary content.
* @param self A pointer to the @a RP-DATA message to serialize.
* @param output A pointer to the @a output buffer.
* @retval Zero if succeed and non-zero error code otherwise.
*
* @sa @ref tsms_rpdu_message_serialize
*
* See For more information, see @ref tsms_rpdu_group_DATA "RP-DATA".
*/
#define tsms_rpdu_data_create_mo(mr, smsc, tpdu) tsms_rpdu_data_create(mr, smsc, tpdu, tsk_true)
#define tsms_rpdu_data_create_mt(mr, smsc, tpdu) tsms_rpdu_data_create(mr, smsc, tpdu, tsk_false)
#define tsms_rpdu_data_serialize(self, output) tsms_rpdu_message_serialize(TSMS_RPDU_MESSAGE(self), output)

// set tpdu

TINYSMS_GEXTERN const tsk_object_def_t *tsms_rpdu_data_def_t;

/** RP-SMMA as per 3GPP TS 24.011 section 7.3.2. */
typedef struct tsms_rpdu_smma_s
{
	TSMS_DECLARE_RPDU_MESSAGE;
}
tsms_rpdu_smma_t;

/** cast any pointer to @ref tsms_rpdu_smma_t* */
#define TSMS_RPDU_SMMA(self) ((tsms_rpdu_smma_t*)(self))

TINYSMS_API tsms_rpdu_smma_t* tsms_rpdu_smma_create(uint8_t mr);

/**@ingroup tsms_rpdu_group
* @def tsms_rpdu_smma_serialize
* Serialize a @a RP-SMMA message as binary content.
* @param self A pointer to the @a RP-SMMA message to serialize.
* @param output A pointer to the @a output buffer.
* @retval Zero if succeed and non-zero error code otherwise.
*
* @sa @ref tsms_rpdu_message_serialize
*
* See For more information, see @ref tsms_rpdu_group_SMMA "RP-SMMA".
*/
#define tsms_rpdu_smma_serialize(self, output) tsms_rpdu_message_serialize(TSMS_RPDU_MESSAGE(self), output)

TINYSMS_GEXTERN const tsk_object_def_t *tsms_rpdu_smma_def_t;

/** RP-ACK as per 3GPP TS 24.011 section 7.3.3. */
typedef struct tsms_rpdu_ack_s
{
	TSMS_DECLARE_RPDU_MESSAGE;

	// section 8.2.5.3
	tsk_buffer_t* udata;
}
tsms_rpdu_ack_t;

/** cast any pointer to @ref tsms_rpdu_ack_t* */
#define TSMS_RPDU_ACK(self) ((tsms_rpdu_ack_t*)(self))

TINYSMS_API tsms_rpdu_ack_t* tsms_rpdu_ack_create(uint8_t mr, const tsms_tpdu_message_t* tpdu, tsk_bool_t MobOrig);

/**@ingroup tsms_rpdu_group
* @def tsms_rpdu_ack_create_mo
* Creates a Mobile Originated @a RP-ACK message.
* @a RP-ACK is sent between the MSC and the mobile station in both directions and used to relay the acknowledgement of a RP-DATA or RP-SMMA message reception.
* For more information, please refer to 3GPP TS 24.011 section 7.3.2.3
* @param mr @a RP-Message Reference as per 3GPP TS 24.011 section 8.2.3.
* @param tpdu A Pointer to the @a TP-Message to include as RP-User data.
* @retval Mobile Originated @a RP-ACK message.
* @sa @ref tsms_rpdu_ack_create_mt<br>@ref tsms_rpdu_ack_create
*
* See For more information, see @ref tsms_rpdu_group_ACK "RP-ACK".
*/
/**@ingroup tsms_rpdu_group
* @def tsms_rpdu_ack_create_mt
* Creates a Mobile Terminated @a RP-ACK message.
* @a RP-ACK is sent between the MSC and the mobile station in both directions and used to relay the acknowledgement of a RP-DATA or RP-SMMA message reception.
* For more information, please refer to 3GPP TS 24.011 section 7.3.2.3
* @param mr @a RP-Message Reference as per 3GPP TS 24.011 section 8.2.3.
* @param tpdu A Pointer to the @a TP-Message to include as RP-User data.
* @retval Mobile Terminated @a RP-ACK message.
* @sa @ref tsms_rpdu_ack_create_mo<br>@ref tsms_rpdu_ack_create
*
* See For more information, see @ref tsms_rpdu_group_ACK "RP-ACK".
*/
/**@ingroup tsms_rpdu_group
* @def tsms_rpdu_ack_serialize
* Serialize a @a RP-ACK message as binary content.
* @param self A pointer to the @a RP-ACK message to serialize.
* @param output A pointer to the @a output buffer.
* @retval Zero if succeed and non-zero error code otherwise.
*
* @sa @ref tsms_rpdu_message_serialize
*
* See For more information, see @ref tsms_rpdu_group_ACK "RP-ACK".
*/
#define tsms_rpdu_ack_create_mo(mr, tpdu) tsms_rpdu_ack_create(mr, tpdu, tsk_true)
#define tsms_rpdu_ack_create_mt(mr, tpdu) tsms_rpdu_ack_create(mr, tpdu, tsk_false)
#define tsms_rpdu_ack_serialize(self, output) tsms_rpdu_message_serialize(TSMS_RPDU_MESSAGE(self), output)

TINYSMS_GEXTERN const tsk_object_def_t *tsms_rpdu_ack_def_t;

/** RP-ERROR as per 3GPP TS 24.011 section 7.3.4. */
typedef struct tsms_rpdu_error_s
{
	TSMS_DECLARE_RPDU_MESSAGE;
	
	// section 8.2.5.4
	uint8_t cause [3]; //2-3o
	// section 8.2.5.3
	tsk_buffer_t* udata;
}
tsms_rpdu_error_t;

/** cast any pointer to @ref tsms_rpdu_error_t* */
#define TSMS_RPDU_ERROR(self) ((tsms_rpdu_error_t*)(self))

TINYSMS_API tsms_rpdu_error_t* tsms_rpdu_error_create(uint8_t mr, const tsms_tpdu_message_t* tpdu, uint8_t cause, tsk_bool_t MobOrig);

/**@ingroup tsms_rpdu_group
* @def tsms_rpdu_error_create_mo
* Creates a Mobile Originated @a RP-ERROR message.
* @a RP-ERROR is sent between the MSC and the mobile station in both directions and used to relay an error cause from an erroneous short message or notification transfer attempt.
* For more information, please refer to 3GPP TS 24.011 section 7.3.2.4.
* @param mr @a RP-Message Reference as per 3GPP TS 24.011 section 8.2.3.
* @param tpdu A Pointer to the @a TP-Message to include as RP-User data.
* @param cause RP-Cause value as per 3GPP TS 24.011 section 8.2.5.4.
* @retval Mobile Originated @a RP-ERROR message.
* @sa @ref tsms_rpdu_error_create_mt<br>@ref tsms_rpdu_error_create
*
* See For more information, see @ref tsms_rpdu_group_ERROR "RP-ERROR".
*/
/**@ingroup tsms_rpdu_group
* @def tsms_rpdu_error_create_mt
* Creates a Mobile Terminated @a RP-ERROR message.
* @a RP-ERROR is sent between the MSC and the mobile station in both directions and used to relay an error cause from an erroneous short message or notification transfer attempt.
* For more information, please refer to 3GPP TS 24.011 section 7.3.2.4.
* @param mr @a RP-Message Reference as per 3GPP TS 24.011 section 8.2.3.
* @param tpdu A Pointer to the @a TP-Message to include as RP-User data.
* @param cause RP-Cause value as per 3GPP TS 24.011 section 8.2.5.4.
* @retval Mobile Terminated @a RP-ERROR message.
* @sa @ref tsms_rpdu_error_create_mo<br>@ref tsms_rpdu_error_create
*
* See For more information, see @ref tsms_rpdu_group_ERROR "RP-ERROR".
*/
/**@ingroup tsms_rpdu_group
* @def tsms_rpdu_error_serialize
* Serialize a @a RP-ERROR message as binary content.
* @param self A pointer to the @a RP-ERROR message to serialize.
* @param output A pointer to the @a output buffer.
* @retval Zero if succeed and non-zero error code otherwise.
*
* @sa @ref tsms_rpdu_message_serialize
*
* See For more information, see @ref tsms_rpdu_group_ERROR "RP-ERROR".
*/
#define tsms_rpdu_error_create_mo(mr, tpdu, cause) tsms_rpdu_error_create(mr, tpdu, cause, tsk_true)
#define tsms_rpdu_error_create_mt(mr, tpdu, cause) tsms_rpdu_error_create(mr, tpdu, cause, tsk_false)
#define tsms_rpdu_error_serialize(self, output) tsms_rpdu_message_serialize(TSMS_RPDU_MESSAGE(self), output)

TINYSMS_GEXTERN const tsk_object_def_t *tsms_rpdu_error_def_t;


TSMS_END_DECLS

#endif /* TINYSMS_TSMS_RPDU_H */
OpenPOWER on IntegriCloud