enum.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. /*
  2. * Asterisk -- An open source telephony toolkit.
  3. *
  4. * Copyright (C) 1999 - 2005, Digium, Inc.
  5. *
  6. * Mark Spencer <markster@digium.com>
  7. *
  8. * See http://www.asterisk.org for more information about
  9. * the Asterisk project. Please do not directly contact
  10. * any of the maintainers of this project for assistance;
  11. * the project provides a web site, mailing lists and IRC
  12. * channels for your use.
  13. *
  14. * This program is free software, distributed under the terms of
  15. * the GNU General Public License Version 2. See the LICENSE file
  16. * at the top of the source tree.
  17. */
  18. /*! \file enum.h
  19. \brief DNS and ENUM functions
  20. */
  21. #ifndef _ASTERISK_ENUM_H
  22. #define _ASTERISK_ENUM_H
  23. #include "asterisk/channel.h"
  24. struct naptr {
  25. unsigned short order;
  26. unsigned short pref;
  27. } __attribute__((__packed__));
  28. struct enum_naptr_rr {
  29. struct naptr naptr; /*!< order and preference of RR */
  30. char *result; /*!< result of naptr parsing,e.g.: tel:+5553 */
  31. char *tech; /*!< Technology (from URL scheme) */
  32. int sort_pos; /*!< sort position */
  33. };
  34. struct enum_context {
  35. char *dst; /*!< Destination part of URL from ENUM */
  36. int dstlen; /*!< Length */
  37. char *tech; /*!< Technology (from URL scheme) */
  38. int techlen; /*!< Length */
  39. char *txt; /*!< TXT record in TXT lookup */
  40. int txtlen; /*!< Length */
  41. char *naptrinput; /*!< The number to lookup */
  42. int position; /*!< specifies position of required RR */
  43. int count; /*!< used as counter for RRs */
  44. int options; /*!< options , see ENUMLOOKUP_OPTIONS_* defined above */
  45. struct enum_naptr_rr *naptr_rrs; /*!< array of parsed NAPTR RRs */
  46. int naptr_rrs_count; /*!< Size of array naptr_rrs */
  47. };
  48. /*! \brief Lookup entry in ENUM
  49. \param chan Channel
  50. \param number E164 number with or without the leading +
  51. \param location Number returned (or SIP uri)
  52. \param maxloc Max length
  53. \param technology Technology (from url scheme in response)
  54. You can set it to get particular answer RR, if there are many techs in DNS response, example: "sip"
  55. If you need any record, then set it to "ALL" string
  56. \param maxtech Max length
  57. \param suffix Zone suffix (WARNING: No defaults here any more)
  58. \param options Options
  59. 'c' - Count number of NAPTR RR
  60. number - Position of the requested RR in the answer list
  61. 'u' - Full URI return (does not strip URI scheme)
  62. 'i' - Infrastructure ENUM lookup
  63. 's' - ISN based lookup
  64. 'd' - Direct DNS query
  65. \param record The position of required RR in the answer list
  66. \param argcontext Argument for caching results into an enum_context pointer (NULL is used for not caching)
  67. \retval 1 if found
  68. \retval 0 if not found
  69. \retval -1 on hangup
  70. */
  71. int ast_get_enum(struct ast_channel *chan, const char *number, char *location, int maxloc, char *technology,
  72. int maxtech, char* suffix, char* options, unsigned int record, struct enum_context **argcontext);
  73. /*! \brief Lookup DNS TXT record (used by app TXTCIDnum)
  74. *
  75. * Really has nothing to do with enum, but anyway...
  76. * Actually, there is now an internet-draft which describes how callerID should
  77. * be stored in ENUM domains: draft-ietf-enum-cnam-04.txt
  78. * The algorithm implemented here will thus be obsolete soon.
  79. *
  80. * \param chan Channel
  81. * \param number E164 number with or without the leading +
  82. * \param txt Text string (return value)
  83. * \param maxtxt Max length of "txt"
  84. * \param suffix Zone suffix
  85. * \version 1.6.1 new suffix parameter to take into account caller ids that aren't in e164.arpa
  86. * \version 1.6.1 removed parameters location, maxloc, technology, maxtech as all the information
  87. * is stored the txt string
  88. */
  89. int ast_get_txt(struct ast_channel *chan, const char *number, char *txt, int maxtxt, char *suffix);
  90. int ast_enum_init(void);
  91. int ast_enum_reload(void);
  92. #endif /* _ASTERISK_ENUM_H */