tsms_rpdu.h 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245
  1. /*
  2. * Copyright (C) 2009 Mamadou Diop.
  3. *
  4. * Contact: Mamadou Diop <diopmamadou [at) doubango (DOT) org>
  5. *
  6. * This file is part of Open Source Doubango Framework.
  7. *
  8. * DOUBANGO is free software: you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation, either version 3 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * DOUBANGO is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with DOUBANGO.
  20. *
  21. */
  22. /**@file tsms_rpdu.h
  23. * @brief SMS RPDU encoder/decoder as per 3GPP TS 23.011.
  24. *
  25. * @author Mamadou Diop <diopmamadou [at) doubango (DOT) org>
  26. *
  27. */
  28. #ifndef TINYSMS_TSMS_RPDU_H
  29. #define TINYSMS_TSMS_RPDU_H
  30. #include "tinysms_config.h"
  31. #include "tinysms/tsms_common.h"
  32. TSMS_BEGIN_DECLS
  33. /** @a RP-DATA as per 3GPP TS 24.011 section 7.3.1. */
  34. typedef struct tsms_rpdu_data_s {
  35. TSMS_DECLARE_RPDU_MESSAGE;
  36. // section 8.2.5.1
  37. tsms_address_t *oa;
  38. //section 8.2.5.2
  39. tsms_address_t *da;
  40. // section 8.2.5.3
  41. tsk_buffer_t* udata;
  42. }
  43. tsms_rpdu_data_t;
  44. /** cast any pointer to @ref tsms_rpdu_data_t* */
  45. #define TSMS_RPDU_DATA(self) ((tsms_rpdu_data_t*)(self))
  46. 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);
  47. /**@ingroup tsms_rpdu_group
  48. * @def tsms_rpdu_data_create_mo
  49. * Creates a Mobile Originated @a RP-DATA message.
  50. * @a RP-DATA messages are use to relay the TPDUs.
  51. * For more information, please refer to 3GPP TS 24.011 section 7.3.1.
  52. * @param mr @a RP-Message Reference as per 3GPP TS 24.011 section 8.2.3.
  53. * @param smsc The address of the SMSC. e.g. "+331253688".
  54. * @param tpdu A Pointer to the @a TP-Message to relay.
  55. * @retval Mobile Originated @a RP-DATA message.
  56. * @sa @ref tsms_rpdu_data_create_mt<br>@ref tsms_rpdu_data_create
  57. *
  58. * See For more information, see @ref tsms_rpdu_group_DATA "RP-DATA".
  59. */
  60. /**@ingroup tsms_rpdu_group
  61. * @def tsms_rpdu_data_create_mt
  62. * Creates a Mobile Terminated @a RP-DATA message.
  63. * @a RP-DATA messages are use to relay the TPDUs.
  64. * For more information, please refer to 3GPP TS 24.011 section 7.3.1.
  65. * @param mr RP-Message Reference as per 3GPP TS 24.011 section 8.2.3.
  66. * @param smsc The address of the SMSC. e.g. "+331253688".
  67. * @param tpdu A Pointer to the @a TP-Message to relay.
  68. * @retval Mobile Terminated RP-DATA message.
  69. * @sa @ref tsms_rpdu_data_create_mo<br>@ref tsms_rpdu_data_create
  70. *
  71. * See For more information, see @ref tsms_rpdu_group_DATA "RP-DATA".
  72. */
  73. /**@ingroup tsms_rpdu_group
  74. * @def tsms_rpdu_data_serialize
  75. * Serialize a @a RP-DATA message as binary content.
  76. * @param self A pointer to the @a RP-DATA message to serialize.
  77. * @param output A pointer to the @a output buffer.
  78. * @retval Zero if succeed and non-zero error code otherwise.
  79. *
  80. * @sa @ref tsms_rpdu_message_serialize
  81. *
  82. * See For more information, see @ref tsms_rpdu_group_DATA "RP-DATA".
  83. */
  84. #define tsms_rpdu_data_create_mo(mr, smsc, tpdu) tsms_rpdu_data_create(mr, smsc, tpdu, tsk_true)
  85. #define tsms_rpdu_data_create_mt(mr, smsc, tpdu) tsms_rpdu_data_create(mr, smsc, tpdu, tsk_false)
  86. #define tsms_rpdu_data_serialize(self, output) tsms_rpdu_message_serialize(TSMS_RPDU_MESSAGE(self), output)
  87. // set tpdu
  88. TINYSMS_GEXTERN const tsk_object_def_t *tsms_rpdu_data_def_t;
  89. /** RP-SMMA as per 3GPP TS 24.011 section 7.3.2. */
  90. typedef struct tsms_rpdu_smma_s {
  91. TSMS_DECLARE_RPDU_MESSAGE;
  92. }
  93. tsms_rpdu_smma_t;
  94. /** cast any pointer to @ref tsms_rpdu_smma_t* */
  95. #define TSMS_RPDU_SMMA(self) ((tsms_rpdu_smma_t*)(self))
  96. TINYSMS_API tsms_rpdu_smma_t* tsms_rpdu_smma_create(uint8_t mr);
  97. /**@ingroup tsms_rpdu_group
  98. * @def tsms_rpdu_smma_serialize
  99. * Serialize a @a RP-SMMA message as binary content.
  100. * @param self A pointer to the @a RP-SMMA message to serialize.
  101. * @param output A pointer to the @a output buffer.
  102. * @retval Zero if succeed and non-zero error code otherwise.
  103. *
  104. * @sa @ref tsms_rpdu_message_serialize
  105. *
  106. * See For more information, see @ref tsms_rpdu_group_SMMA "RP-SMMA".
  107. */
  108. #define tsms_rpdu_smma_serialize(self, output) tsms_rpdu_message_serialize(TSMS_RPDU_MESSAGE(self), output)
  109. TINYSMS_GEXTERN const tsk_object_def_t *tsms_rpdu_smma_def_t;
  110. /** RP-ACK as per 3GPP TS 24.011 section 7.3.3. */
  111. typedef struct tsms_rpdu_ack_s {
  112. TSMS_DECLARE_RPDU_MESSAGE;
  113. // section 8.2.5.3
  114. tsk_buffer_t* udata;
  115. }
  116. tsms_rpdu_ack_t;
  117. /** cast any pointer to @ref tsms_rpdu_ack_t* */
  118. #define TSMS_RPDU_ACK(self) ((tsms_rpdu_ack_t*)(self))
  119. TINYSMS_API tsms_rpdu_ack_t* tsms_rpdu_ack_create(uint8_t mr, const tsms_tpdu_message_t* tpdu, tsk_bool_t MobOrig);
  120. /**@ingroup tsms_rpdu_group
  121. * @def tsms_rpdu_ack_create_mo
  122. * Creates a Mobile Originated @a RP-ACK message.
  123. * @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.
  124. * For more information, please refer to 3GPP TS 24.011 section 7.3.2.3
  125. * @param mr @a RP-Message Reference as per 3GPP TS 24.011 section 8.2.3.
  126. * @param tpdu A Pointer to the @a TP-Message to include as RP-User data.
  127. * @retval Mobile Originated @a RP-ACK message.
  128. * @sa @ref tsms_rpdu_ack_create_mt<br>@ref tsms_rpdu_ack_create
  129. *
  130. * See For more information, see @ref tsms_rpdu_group_ACK "RP-ACK".
  131. */
  132. /**@ingroup tsms_rpdu_group
  133. * @def tsms_rpdu_ack_create_mt
  134. * Creates a Mobile Terminated @a RP-ACK message.
  135. * @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.
  136. * For more information, please refer to 3GPP TS 24.011 section 7.3.2.3
  137. * @param mr @a RP-Message Reference as per 3GPP TS 24.011 section 8.2.3.
  138. * @param tpdu A Pointer to the @a TP-Message to include as RP-User data.
  139. * @retval Mobile Terminated @a RP-ACK message.
  140. * @sa @ref tsms_rpdu_ack_create_mo<br>@ref tsms_rpdu_ack_create
  141. *
  142. * See For more information, see @ref tsms_rpdu_group_ACK "RP-ACK".
  143. */
  144. /**@ingroup tsms_rpdu_group
  145. * @def tsms_rpdu_ack_serialize
  146. * Serialize a @a RP-ACK message as binary content.
  147. * @param self A pointer to the @a RP-ACK message to serialize.
  148. * @param output A pointer to the @a output buffer.
  149. * @retval Zero if succeed and non-zero error code otherwise.
  150. *
  151. * @sa @ref tsms_rpdu_message_serialize
  152. *
  153. * See For more information, see @ref tsms_rpdu_group_ACK "RP-ACK".
  154. */
  155. #define tsms_rpdu_ack_create_mo(mr, tpdu) tsms_rpdu_ack_create(mr, tpdu, tsk_true)
  156. #define tsms_rpdu_ack_create_mt(mr, tpdu) tsms_rpdu_ack_create(mr, tpdu, tsk_false)
  157. #define tsms_rpdu_ack_serialize(self, output) tsms_rpdu_message_serialize(TSMS_RPDU_MESSAGE(self), output)
  158. TINYSMS_GEXTERN const tsk_object_def_t *tsms_rpdu_ack_def_t;
  159. /** RP-ERROR as per 3GPP TS 24.011 section 7.3.4. */
  160. typedef struct tsms_rpdu_error_s {
  161. TSMS_DECLARE_RPDU_MESSAGE;
  162. // section 8.2.5.4
  163. uint8_t cause [3]; //2-3o
  164. // section 8.2.5.3
  165. tsk_buffer_t* udata;
  166. }
  167. tsms_rpdu_error_t;
  168. /** cast any pointer to @ref tsms_rpdu_error_t* */
  169. #define TSMS_RPDU_ERROR(self) ((tsms_rpdu_error_t*)(self))
  170. 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);
  171. /**@ingroup tsms_rpdu_group
  172. * @def tsms_rpdu_error_create_mo
  173. * Creates a Mobile Originated @a RP-ERROR message.
  174. * @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.
  175. * For more information, please refer to 3GPP TS 24.011 section 7.3.2.4.
  176. * @param mr @a RP-Message Reference as per 3GPP TS 24.011 section 8.2.3.
  177. * @param tpdu A Pointer to the @a TP-Message to include as RP-User data.
  178. * @param cause RP-Cause value as per 3GPP TS 24.011 section 8.2.5.4.
  179. * @retval Mobile Originated @a RP-ERROR message.
  180. * @sa @ref tsms_rpdu_error_create_mt<br>@ref tsms_rpdu_error_create
  181. *
  182. * See For more information, see @ref tsms_rpdu_group_ERROR "RP-ERROR".
  183. */
  184. /**@ingroup tsms_rpdu_group
  185. * @def tsms_rpdu_error_create_mt
  186. * Creates a Mobile Terminated @a RP-ERROR message.
  187. * @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.
  188. * For more information, please refer to 3GPP TS 24.011 section 7.3.2.4.
  189. * @param mr @a RP-Message Reference as per 3GPP TS 24.011 section 8.2.3.
  190. * @param tpdu A Pointer to the @a TP-Message to include as RP-User data.
  191. * @param cause RP-Cause value as per 3GPP TS 24.011 section 8.2.5.4.
  192. * @retval Mobile Terminated @a RP-ERROR message.
  193. * @sa @ref tsms_rpdu_error_create_mo<br>@ref tsms_rpdu_error_create
  194. *
  195. * See For more information, see @ref tsms_rpdu_group_ERROR "RP-ERROR".
  196. */
  197. /**@ingroup tsms_rpdu_group
  198. * @def tsms_rpdu_error_serialize
  199. * Serialize a @a RP-ERROR message as binary content.
  200. * @param self A pointer to the @a RP-ERROR message to serialize.
  201. * @param output A pointer to the @a output buffer.
  202. * @retval Zero if succeed and non-zero error code otherwise.
  203. *
  204. * @sa @ref tsms_rpdu_message_serialize
  205. *
  206. * See For more information, see @ref tsms_rpdu_group_ERROR "RP-ERROR".
  207. */
  208. #define tsms_rpdu_error_create_mo(mr, tpdu, cause) tsms_rpdu_error_create(mr, tpdu, cause, tsk_true)
  209. #define tsms_rpdu_error_create_mt(mr, tpdu, cause) tsms_rpdu_error_create(mr, tpdu, cause, tsk_false)
  210. #define tsms_rpdu_error_serialize(self, output) tsms_rpdu_message_serialize(TSMS_RPDU_MESSAGE(self), output)
  211. TINYSMS_GEXTERN const tsk_object_def_t *tsms_rpdu_error_def_t;
  212. TSMS_END_DECLS
  213. #endif /* TINYSMS_TSMS_RPDU_H */