enum.h

Go to the documentation of this file.
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;                    /*!< specifies position of required RR */
00049    int count;                       /*!< used as counter for RRs */
00050    int options;                     /*!< options , see ENUMLOOKUP_OPTIONS_* defined above */
00051    struct enum_naptr_rr *naptr_rrs; /*!< array of parsed NAPTR RRs */
00052    int naptr_rrs_count;             /*!< Size of array naptr_rrs */
00053 };
00054 
00055 
00056 /*! \brief Lookup entry in ENUM
00057    \param chan Channel
00058    \param number   E164 number with or without the leading +
00059    \param location Number returned  (or SIP uri)
00060    \param maxloc  Max length
00061    \param technology Technology (from url scheme in response)
00062                        You can set it to get particular answer RR, if there are many techs in DNS response, example: "sip"
00063                        If you need any record, then set it to "ALL" string
00064    \param maxtech  Max length
00065    \param suffix   Zone suffix (WARNING: No defaults here any more)
00066    \param options  Options
00067             'c'    - Count number of NAPTR RR
00068             number - Position of the requested RR in the answer list
00069             'u'    - Full URI return (does not strip URI scheme)
00070             'i'    - Infrastructure ENUM lookup
00071             's'    - ISN based lookup
00072             'd'    - Direct DNS query
00073    \param record   The position of required RR in the answer list
00074    \param argcontext   Argument for caching results into an enum_context pointer (NULL is used for not caching)
00075    \retval 1 if found
00076    \retval 0 if not found
00077    \retval -1 on hangup
00078 */
00079 int ast_get_enum(struct ast_channel *chan, const char *number, char *location, int maxloc, char *technology,
00080       int maxtech, char* suffix, char* options, unsigned int record, struct enum_context **argcontext);
00081 
00082 /*!   \brief Lookup DNS TXT record (used by app TXTCIDnum)
00083  *
00084  * Really has nothing to do with enum, but anyway...
00085  * Actually, there is now an internet-draft which describes how callerID should
00086  * be stored in ENUM domains: draft-ietf-enum-cnam-04.txt
00087  * The algorithm implemented here will thus be obsolete soon.
00088  *
00089  * \param chan Channel
00090  * \param number   E164 number with or without the leading +
00091  * \param txt  Text string (return value)
00092  * \param maxtxt  Max length of "txt"
00093  * \param suffix  Zone suffix
00094  * \version 1.6.1 new suffix parameter to take into account caller ids that aren't in e164.arpa
00095  * \version 1.6.1 removed parameters location, maxloc, technology, maxtech as all the information
00096  * is stored the txt string
00097  */
00098 int ast_get_txt(struct ast_channel *chan, const char *number, char *txt, int maxtxt, char *suffix);
00099 
00100 int ast_enum_init(void);
00101 int ast_enum_reload(void);
00102 
00103 #endif /* _ASTERISK_ENUM_H */

Generated on Thu Apr 16 06:27:33 2015 for Asterisk - The Open Source Telephony Project by  doxygen 1.5.6