00001 /* 00002 * Asterisk -- An open source telephony toolkit. 00003 * 00004 * Copyright (C) 1999 - 2005, Digium, Inc. 00005 * 00006 * Mark Spencer <markster@digium.com> 00007 * 00008 * See http://www.asterisk.org for more information about 00009 * the Asterisk project. Please do not directly contact 00010 * any of the maintainers of this project for assistance; 00011 * the project provides a web site, mailing lists and IRC 00012 * channels for your use. 00013 * 00014 * This program is free software, distributed under the terms of 00015 * the GNU General Public License Version 2. See the LICENSE file 00016 * at the top of the source tree. 00017 */ 00018 00019 /*! \file enum.h 00020 \brief DNS and ENUM functions 00021 */ 00022 00023 #ifndef _ASTERISK_ENUM_H 00024 #define _ASTERISK_ENUM_H 00025 00026 #include "asterisk/channel.h" 00027 00028 struct naptr { 00029 unsigned short order; 00030 unsigned short pref; 00031 } __attribute__((__packed__)); 00032 00033 struct enum_naptr_rr { 00034 struct naptr naptr; /*!< order and preference of RR */ 00035 char *result; /*!< result of naptr parsing,e.g.: tel:+5553 */ 00036 char *tech; /*!< Technology (from URL scheme) */ 00037 int sort_pos; /*!< sort position */ 00038 }; 00039 00040 struct enum_context { 00041 char *dst; /*!< Destination part of URL from ENUM */ 00042 int dstlen; /*!< Length */ 00043 char *tech; /*!< Technology (from URL scheme) */ 00044 int techlen; /*!< Length */ 00045 char *txt; /*!< TXT record in TXT lookup */ 00046 int txtlen; /*!< Length */ 00047 char *naptrinput; /*!< The number to lookup */ 00048 int position; /*!< used as counter for RRs or specifies position of required RR */ 00049 int options; /*!< options , see ENUMLOOKUP_OPTIONS_* defined above */ 00050 struct enum_naptr_rr *naptr_rrs; /*!< array of parsed NAPTR RRs */ 00051 int naptr_rrs_count; /*!< Size of array naptr_rrs */ 00052 }; 00053 00054 00055 /*! \brief Lookup entry in ENUM 00056 \param chan Channel 00057 \param number E164 number with or without the leading + 00058 \param location Number returned (or SIP uri) 00059 \param maxloc Max length 00060 \param technology Technology (from url scheme in response) 00061 You can set it to get particular answer RR, if there are many techs in DNS response, example: "sip" 00062 If you need any record, then set it to empty string 00063 \param maxtech Max length 00064 \param suffix Zone suffix (if is NULL then use enum.conf 'search' variable) 00065 \param options Options ('c' to count number of NAPTR RR) 00066 \param record The position of required RR in the answer list 00067 \param argcontext Argument for caching results into an enum_context pointer (NULL is used for not caching) 00068 \retval 1 if found 00069 \retval 0 if not found 00070 \retval -1 on hangup 00071 */ 00072 int ast_get_enum(struct ast_channel *chan, const char *number, char *location, int maxloc, char *technology, 00073 int maxtech, char* suffix, char* options, unsigned int record, struct enum_context **argcontext); 00074 00075 /*! \brief Lookup DNS TXT record (used by app TXTCIDnum 00076 \param chan Channel 00077 \param number E164 number with or without the leading + 00078 \param location Number returned (or SIP uri) 00079 \param maxloc Max length of number 00080 \param technology Technology (not used in TXT records) 00081 \param maxtech Max length 00082 \param txt Text string (return value) 00083 \param maxtxt Max length of "txt" 00084 */ 00085 int ast_get_txt(struct ast_channel *chan, const char *number, char *location, int maxloc, char *technology, int maxtech, char *txt, int maxtxt); 00086 00087 int ast_enum_init(void); 00088 int ast_enum_reload(void); 00089 00090 #endif /* _ASTERISK_ENUM_H */