tsms_address.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  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_address.h
  23. * @brief SMS address encoder/decoder.
  24. *
  25. * @author Mamadou Diop <diopmamadou [at) doubango (DOT) org>
  26. *
  27. */
  28. #ifndef TINYSMS_TSMS_ADDRESS_H
  29. #define TINYSMS_TSMS_ADDRESS_H
  30. #include "tinysms_config.h"
  31. #include "tsk_buffer.h"
  32. TSMS_BEGIN_DECLS
  33. typedef uint8_t tsms_address_string_t[13]; /* 12 + (+) */
  34. /** Address type
  35. */
  36. typedef enum tsms_address_type_e {
  37. tsms_addr_oa,
  38. tsms_addr_da,
  39. tsms_addr_smsc,
  40. }
  41. tsms_address_type_t;
  42. /** Type-of-number
  43. * 3GPP TS 23.040 v910 section 9.1.2.5.
  44. */
  45. typedef enum tsms_address_ton_e {
  46. /** "Unknown" is used when the user or network has no a priori information about the numbering plan. In
  47. this case, the Address-Value field is organized according to the network dialling plan, e.g. prefix or
  48. escape digits might be present.*/
  49. tsms_addr_ton_unknown = 0x00, // 0b000
  50. /** International number
  51. The international format shall be accepted also when the message is destined to a recipient in the
  52. same country as the MSC. */
  53. tsms_addr_ton_international = 0x01, // 0b001
  54. /** National number
  55. Prefix or escape digits shall not be included */
  56. tsms_addr_ton_national = 0x02, // 0b010
  57. /** "Network specific number" is used to indicate administration/service number specific to the serving
  58. network, e.g. used to access an operator. */
  59. tsms_addr_ton_network_specific = 0x03, // 0b011
  60. /** "Subscriber number" is used when a specific short number representation is stored in one or more
  61. SCs as part of a higher layer application. (Note that "Subscriber number" shall only be used in
  62. connection with the proper PID referring to this application). */
  63. tsms_addr_ton_subscriber = 0x04, // 0b100
  64. /** Alphanumeric, (coded according to GSM TS 03.38 7-bit default alphabet) */
  65. tsms_addr_ton_alphanumeric = 0x05, // 0b101
  66. /** Abbreviated number */
  67. tsms_addr_ton_abbreviated = 0x06, // 0b110
  68. /** Reserved for extension */
  69. tsms_addr_ton_reserved = 0x07, // 0b111
  70. }
  71. tsms_address_ton_t;
  72. /** Numbering-Plan-Identification
  73. * 3GPP TS 23.040 v910 section 9.1.2.5.
  74. */
  75. typedef enum tsms_address_npi_e {
  76. /* 0000 */ tsms_addr_npi_unknown = 0x00, /**< Unknown */
  77. /* 0001 */ tsms_addr_npi_isdn = 0x01, /**< ISDN/telephone numbering plan (E.164/E.163) */
  78. /* 0011 */ tsms_addr_npi_x121 = 0x03, /**< Data numbering plan (X.121) */
  79. /* 0100 */ tsms_addr_npi_telex = 0x04, /**< Telex numbering plan */
  80. /* 1000 */ tsms_addr_npi_national = 0x08, /**< National numbering plan */
  81. /* 1001 */ tsms_addr_npi_private = 0x09, /**< Private numbering plan */
  82. /* 1010 */ tsms_addr_npi_ermes = 0x0A, /**< ERMES numbering plan (ETSI DE/PS 3 01-3) */
  83. /* 1111 */ tsms_addr_npi_reserved = 0x0F, /**< Reserved for extension */
  84. }
  85. tsms_address_npi_t;
  86. /** Address
  87. */
  88. typedef struct tsms_address_s {
  89. TSK_DECLARE_OBJECT;
  90. // Address Type
  91. tsms_address_ton_t ton; /**< Type-of-number */
  92. tsms_address_npi_t npi; /**< Numbering-Plan-Identification */
  93. tsms_address_type_t type;
  94. char* digits; /* BCD digits */
  95. }
  96. tsms_address_t;
  97. int tsms_address_serialize(const tsms_address_t* address, tsk_buffer_t* output);
  98. tsms_address_t* tsms_address_deserialize(const void* data, tsk_size_t size, tsms_address_type_t xtype, tsk_size_t *length);
  99. tsms_address_t* tsms_address_create(const tsms_address_string_t digits, tsms_address_type_t type);
  100. tsms_address_t* tsms_address_oa_create(const tsms_address_string_t digits);
  101. tsms_address_t* tsms_address_da_create(const tsms_address_string_t digits);
  102. tsms_address_t* tsms_address_smsc_create(const tsms_address_string_t digits);
  103. TINYSMS_GEXTERN const tsk_object_def_t *tsms_address_def_t;
  104. TSMS_END_DECLS
  105. #endif /* TSMS_BEGIN_DECLS */