Asterisk - The Open Source Telephony Project  18.5.0
enum.h
Go to the documentation of this file.
1 /*
2  * Asterisk -- An open source telephony toolkit.
3  *
4  * Copyright (C) 1999 - 2005, Digium, Inc.
5  *
6  * Mark Spencer <[email protected]>
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 
19 /*! \file enum.h
20  \brief DNS and ENUM functions
21 */
22 
23 #ifndef _ASTERISK_ENUM_H
24 #define _ASTERISK_ENUM_H
25 
26 #include "asterisk/channel.h"
27 
28 struct naptr {
29  unsigned short order;
30  unsigned short pref;
31 } __attribute__((__packed__));
32 
33 struct enum_naptr_rr {
34  struct naptr naptr; /*!< order and preference of RR */
35  char *result; /*!< result of naptr parsing,e.g.: tel:+5553 */
36  char *tech; /*!< Technology (from URL scheme) */
37  int sort_pos; /*!< sort position */
38 };
39 
40 struct enum_context {
41  char *dst; /*!< Destination part of URL from ENUM */
42  int dstlen; /*!< Length */
43  char *tech; /*!< Technology (from URL scheme) */
44  int techlen; /*!< Length */
45  char *txt; /*!< TXT record in TXT lookup */
46  int txtlen; /*!< Length */
47  char *naptrinput; /*!< The number to lookup */
48  int position; /*!< specifies position of required RR */
49  int count; /*!< used as counter for RRs */
50  int options; /*!< options , see ENUMLOOKUP_OPTIONS_* defined above */
51  struct enum_naptr_rr *naptr_rrs; /*!< array of parsed NAPTR RRs */
52  int naptr_rrs_count; /*!< Size of array naptr_rrs */
53 };
54 
55 
56 /*! \brief Lookup entry in ENUM
57  \param chan Channel
58  \param number E164 number with or without the leading +
59  \param location Number returned (or SIP uri)
60  \param maxloc Max length
61  \param technology Technology (from url scheme in response)
62  You can set it to get particular answer RR, if there are many techs in DNS response, example: "sip"
63  If you need any record, then set it to "ALL" string
64  \param maxtech Max length
65  \param suffix Zone suffix (WARNING: No defaults here any more)
66  \param options Options
67  'c' - Count number of NAPTR RR
68  number - Position of the requested RR in the answer list
69  'u' - Full URI return (does not strip URI scheme)
70  'i' - Infrastructure ENUM lookup
71  's' - ISN based lookup
72  'd' - Direct DNS query
73  \param record The position of required RR in the answer list
74  \param argcontext Argument for caching results into an enum_context pointer (NULL is used for not caching)
75  \retval 1 if found
76  \retval 0 if not found
77  \retval -1 on hangup
78 */
79 int ast_get_enum(struct ast_channel *chan, const char *number, char *location, int maxloc, char *technology,
80  int maxtech, char* suffix, char* options, unsigned int record, struct enum_context **argcontext);
81 
82 /*! \brief Lookup DNS TXT record (used by app TXTCIDnum)
83  *
84  * Really has nothing to do with enum, but anyway...
85  * Actually, there is now an internet-draft which describes how callerID should
86  * be stored in ENUM domains: draft-ietf-enum-cnam-04.txt
87  * The algorithm implemented here will thus be obsolete soon.
88  *
89  * \param chan Channel
90  * \param number E164 number with or without the leading +
91  * \param txt Text string (return value)
92  * \param maxtxt Max length of "txt"
93  * \param suffix Zone suffix
94  * \version 1.6.1 new suffix parameter to take into account caller ids that aren't in e164.arpa
95  * \version 1.6.1 removed parameters location, maxloc, technology, maxtech as all the information
96  * is stored the txt string
97  */
98 int ast_get_txt(struct ast_channel *chan, const char *number, char *txt, int maxtxt, char *suffix);
99 
100 #endif /* _ASTERISK_ENUM_H */
Main Channel structure associated with a channel.
char * txt
Definition: enum.h:45
int count
Definition: enum.h:49
struct enum_naptr_rr * naptr_rrs
Definition: enum.h:51
unsigned short pref
Definition: enum.h:30
int dstlen
Definition: enum.h:42
int position
Definition: enum.h:48
Number structure.
Definition: app_followme.c:154
int txtlen
Definition: enum.h:46
int techlen
Definition: enum.h:44
General Asterisk PBX channel definitions.
char * dst
Definition: enum.h:41
unsigned short order
Definition: enum.h:29
char * naptrinput
Definition: enum.h:47
char * tech
Definition: enum.h:36
Definition: enum.h:28
int ast_get_txt(struct ast_channel *chan, const char *number, char *txt, int maxtxt, char *suffix)
Lookup DNS TXT record (used by app TXTCIDnum)
Definition: enum.c:995
int ast_get_enum(struct ast_channel *chan, const char *number, char *location, int maxloc, char *technology, int maxtech, char *suffix, char *options, unsigned int record, struct enum_context **argcontext)
Lookup entry in ENUM.
Definition: enum.c:649
char * result
Definition: enum.h:35
int naptr_rrs_count
Definition: enum.h:52
static struct test_options options
char * tech
Definition: enum.h:43
int sort_pos
Definition: enum.h:37
int options
Definition: enum.h:50