tsms_tpdu_command.h 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  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_command.h
  23. * @brief SMS TPDU SMS-COMMAND message as per 3GPP TS 23.040 section 9.2.2.4.
  24. *
  25. * @author Mamadou Diop <diopmamadou [at) doubango (DOT) org>
  26. *
  27. */
  28. #ifndef TINYSMS_TSMS_TPDU_COMMAND_H
  29. #define TINYSMS_TSMS_TPDU_COMMAND_H
  30. #include "tinysms_config.h"
  31. #include "tinysms/tsms_common.h"
  32. TSMS_BEGIN_DECLS
  33. /** TP-Command-Type (TP-CT) as per 3GPP TS 23.040 section 9.2.3.19.
  34. * An 8-bit field.
  35. */
  36. typedef enum tsms_tpdu_cmd_e {
  37. tsms_tpdu_cmd_rel = 0x00, /**< Enquiry relating to previously submitted short message. */
  38. tsms_tpdu_cmd_cancel = 0x01, /**< Cancel Status Report Request relating to previously submitted short message. */
  39. tsms_tpdu_cmd_delete = 0x02, /**< Delete previously submitted Short Message. */
  40. tsms_tpdu_cmd_enable_status = 0x03, /**< Enable Status Report Request relating to previously submitted short message. */
  41. /* 00000100..00011111 ==> Reserved */
  42. /* 11100000..11111111 ==> Values specific for each SC */
  43. }
  44. tsms_tpdu_cmd_t;
  45. /** SMS TPDU SMS-COMMAND message as per 3GPP TS 23.040 section 9.2.2.4.
  46. */
  47. typedef struct tsms_tpdu_command_s {
  48. TSMS_DECLARE_TPDU_MESSAGE;
  49. tsms_address_t* smsc;
  50. /** TP-User-Data-Header-Indication (O - 1b)
  51. * Parameter indicating that the TP-CD field contains a Header. */
  52. unsigned udhi:1;
  53. /** TP Status Report Request (O - 1b)
  54. * Parameter indicating if the SMS Command is requesting a status report. */
  55. unsigned srr:1;
  56. /** TP Message Reference (M - I)
  57. * Parameter identifying the SMS COMMAND. */
  58. uint8_t mr;
  59. /** TP Protocol Identifier (M - o)
  60. * Parameter identifying the above layer protocol, if any. */
  61. //(base)uint8_t pid;
  62. /** TP Command Type (M - o)
  63. * Parameter specifying which operation is to be performed on a SM.
  64. * See section 9.2.3.19 */
  65. tsms_tpdu_cmd_t ct;
  66. /** TP Message Number (M - o)
  67. * Parameter indicating which SM in the SC to operate on.
  68. * See section 9.2.3.18 */
  69. uint8_t mn;
  70. /** TP Destination Address (M - 2-12o)
  71. * Parameter indicating the Destination Address to which the TP Command refers. */
  72. tsms_address_t* da;
  73. /** TP Command Data Length (M - o)
  74. * Parameter indicating the length of the TP-CD field in octets. */
  75. //(base)uint8_t cdl;
  76. /** TP Command Data (O - o)
  77. * Parameter containing user data. */
  78. //(base)uint8_t cd;
  79. }
  80. tsms_tpdu_command_t;
  81. /** cast any pointer to @ref tsms_tpdu_command_t* */
  82. #define TSMS_TPDU_COMMAND(self) ((tsms_tpdu_command_t*)(self))
  83. TINYSMS_API tsms_tpdu_command_t* tsms_tpdu_command_create(uint8_t mr, const tsms_address_string_t smsc, const tsms_address_string_t dest, uint8_t msg_num, tsms_tpdu_cmd_t cmd);
  84. /**@ingroup tsms_tpdu_group
  85. * @def tsms_tpdu_command_serialize
  86. * Serializes a @a SMS-COMMAND message as binary content.
  87. * @param self A pointer to the @a SMS-COMMAND (@ref tsms_tpdu_command_t) message to serialize.
  88. * @param output A pointer to the output buffer. Should be valid.
  89. * @retval Zero if succeed and non-zero error code otherwise.
  90. *
  91. * See For more information, see @ref tsms_tpdu_group_COMMAND "SMS-COMMAND".
  92. */
  93. /**@ingroup tsms_tpdu_group
  94. * @def tsms_tpdu_command_tohexastring
  95. * Serializes a @a SMS-COMMAND message as hexa-string content.
  96. * @param self A pointer to the @a SMS-COMMAND (@ref tsms_tpdu_command_t) message to serialize.
  97. * @retval A pointer to the hexa-string if succeed and Null otherwise.
  98. *
  99. * See For more information, see @ref tsms_tpdu_group_COMMAND "SMS-COMMAND".
  100. */
  101. /**@ingroup tsms_tpdu_group
  102. * @def tsms_tpdu_command_set_cmddata
  103. * Sets the content of the @a SMS-COMMAND message.
  104. * @param self A pointer to the @a SMS-COMMAND (@ref tsms_tpdu_command_t).
  105. * @param cdata A pointer to the content.
  106. * @retval Zero if succeed and non-zero error code otherwise.
  107. *
  108. * See For more information, see @ref tsms_tpdu_group_COMMAND "SMS-COMMAND".
  109. */
  110. #define tsms_tpdu_command_serialize(self, output) tsms_tpdu_message_serialize(TSMS_TPDU_MESSAGE(self), output, tsk_true)
  111. #define tsms_tpdu_command_tostring(self) tsms_tpdu_message_tostring(TSMS_TPDU_MESSAGE(self), tsk_true)
  112. #define tsms_tpdu_command_tohexastring(self) tsms_tpdu_message_tohexastring(TSMS_TPDU_MESSAGE(self), tsk_true)
  113. #define tsms_tpdu_command_set_cmddata(self, cdata) tsms_tpdu_message_set_userdata(TSMS_TPDU_MESSAGE(self), cdata, tsms_alpha_8bit)
  114. TINYSMS_GEXTERN const tsk_object_def_t *tsms_tpdu_command_def_t;
  115. TSMS_END_DECLS
  116. #endif /* TINYSMS_TSMS_TPDU_COMMAND_H */