tsms_tpdu_report.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  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_tpdu_report.h
  23. * @brief SMS TPDU SMS-DELIVER-REPORT and SMS-SUBMIT-REPORT message as per 3GPP TS 23.040 section 9.2.2.1a and 9.2.2.2a.
  24. *
  25. * @author Mamadou Diop <diopmamadou [at) doubango (DOT) org>
  26. *
  27. */
  28. #ifndef TINYSMS_TSMS_TPDU_REPORT_H
  29. #define TINYSMS_TSMS_TPDU_REPORT_H
  30. #include "tinysms_config.h"
  31. #include "tinysms/tsms_common.h"
  32. TSMS_BEGIN_DECLS
  33. /** SMS TPDU SMS-DELIVER-REPORT or SMS-SUBMIT-REPORT
  34. * message as per 3GPP TS 23.040 section 9.2.2.1a or 9.2.2.2a.
  35. */
  36. typedef struct tsms_tpdu_report_s {
  37. TSMS_DECLARE_TPDU_MESSAGE;
  38. tsms_address_t* smsc;
  39. /** Indicates whether the Report is for RP-ERROR or not (RP-ACK).*/
  40. tsk_bool_t error;
  41. /** TP-User-Data-Header-Indication (O - 1b)
  42. * Parameter indicating that the TP-UD field contains a Header. */
  43. unsigned udhi:1;
  44. /** TP Failure Cause (M - I)
  45. * Parameter indicating the reason for SMS DELIVER/SUBMIT failure.
  46. See clause 9.2.3.22 */
  47. uint8_t fcs;
  48. /** TP Parameter Indicator (M - o)
  49. * Parameter indicating the presence of any of the optional parameters which follow. */
  50. uint8_t pi;
  51. /** TP Service Centre Time Stamp (M - 7o)
  52. * Parameter identifying the time when the SC received the SMS DELIVER/SUBMIT.
  53. * See clause 9.2.3.11. */
  54. uint8_t scts[7];
  55. /** TP Protocol Identifier (O - o)
  56. * See clause 9.2.3.9. */
  57. //(base)uint8_t pid;
  58. /** TP Data Coding Scheme (O - o)
  59. * See clause 9.2.3.10. */
  60. //(base)uint8_t dcs;
  61. /** TP User Data Length (O- o)
  62. * See clause 9.2.3.16. */
  63. //(base)uint8_t udl;
  64. /** TP User Data (O - v)
  65. * User data. */
  66. //(base)tsk_buffer_t* ud;
  67. }
  68. tsms_tpdu_report_t;
  69. /** cast any pointer to @ref tsms_tpdu_report_t* */
  70. #define TSMS_TPDU_REPORT(self) ((tsms_tpdu_report_t*)(self))
  71. TINYSMS_API tsms_tpdu_report_t* tsms_tpdu_report_create(const tsms_address_string_t smsc, tsk_bool_t submit, tsk_bool_t error);
  72. TINYSMS_API int tsms_tpdu_report_set_fcs(tsms_tpdu_report_t* self, uint8_t code);
  73. #define TSMS_TPDU_REPORT_IS_MO(self) (TSMS_TPDU_MESSAGE(self)->mti == tsms_tpdu_mti_deliver_report_mo)
  74. /**@ingroup tsms_tpdu_group
  75. * @def tsms_tpdu_report_serialize
  76. * Serializes a @a SMS-DELIVER-REPORT or @a SMS-SUBMIT-REPORT message as binary content.
  77. * @param self A pointer to the @a SMS-DELIVER-REPORT or @a SMS-SUBMIT-REPORT (@ref tsms_tpdu_report_t) message to serialize.
  78. * @param output A pointer to the output buffer. Should be valid.
  79. * @retval Zero if succeed and non-zero error code otherwise.
  80. */
  81. /**@ingroup tsms_tpdu_group
  82. * @def tsms_tpdu_report_tohexastring
  83. * Serializes a @a SMS-DELIVER-REPORT or @a SMS-SUBMIT-REPORT message as hexa-string content.
  84. * @param self A pointer to the @a SMS-DELIVER-REPORT or @a SMS-SUBMIT-REPORTT (@ref tsms_tpdu_report_t) message to serialize.
  85. * @retval A pointer to the hexa-string if succeed and Null otherwise.
  86. */
  87. /**@ingroup tsms_tpdu_group
  88. * @def tsms_tpdu_report_set_userdata
  89. * Sets the content of the @a SMS-DELIVER-REPORT or @a SMS-SUBMIT-REPORT message.
  90. * @param self A pointer to the @a SMS-DELIVER-REPORT or @a SMS-SUBMIT-REPORT (@ref tsms_tpdu_report_t).
  91. * @param udata A pointer to the content.
  92. * @param alpha The alphabet used to encode the content.
  93. * @retval Zero if succeed and non-zero error code otherwise.
  94. */
  95. #define tsms_tpdu_report_serialize(self, output) tsms_tpdu_message_serialize(TSMS_TPDU_MESSAGE(self), output, TSMS_TPDU_REPORT_IS_MO(self))
  96. #define tsms_tpdu_report_tostring(self) tsms_tpdu_message_tostring(TSMS_TPDU_MESSAGE(self), TSMS_TPDU_REPORT_IS_MO(self))
  97. #define tsms_tpdu_report_tohexastring(self) tsms_tpdu_message_tohexastring(TSMS_TPDU_MESSAGE(self), TSMS_TPDU_REPORT_IS_MO(self))
  98. #define tsms_tpdu_report_set_userdata(self, udata, alpha) tsms_tpdu_message_set_userdata(TSMS_TPDU_MESSAGE(self), udata, alpha)
  99. TINYSMS_GEXTERN const tsk_object_def_t *tsms_tpdu_report_def_t;
  100. TSMS_END_DECLS
  101. #endif /* TINYSMS_TSMS_TPDU_REPORT_H */