| Asterisk - The Open Source Telephony Project GIT-master-27fb039
    | 
ENUM Support for Asterisk. More...
#include "asterisk.h"#include <sys/socket.h>#include <netinet/in.h>#include <arpa/nameser.h>#include <resolv.h>#include <ctype.h>#include <regex.h>#include "asterisk/module.h"#include "asterisk/enum.h"#include "asterisk/dns.h"#include "asterisk/channel.h"#include "asterisk/config.h"#include "asterisk/utils.h"#include "asterisk/manager.h"
Go to the source code of this file.
| Data Structures | |
| struct | ebl_context | 
| struct | txt_context | 
| Macros | |
| #define | ENUMLOOKUP_BLR_CC 0 | 
| #define | ENUMLOOKUP_BLR_EBL 2 | 
| #define | ENUMLOOKUP_BLR_TXT 1 | 
| #define | ENUMLOOKUP_OPTIONS_COUNT 1 | 
| #define | ENUMLOOKUP_OPTIONS_DIRECT 8 | 
| #define | ENUMLOOKUP_OPTIONS_IENUM 4 | 
| #define | ENUMLOOKUP_OPTIONS_ISN 2 | 
| #define | T_EBL 65300 | 
| Functions | |
| static void | __reg_module (void) | 
| static void | __unreg_module (void) | 
| int | ast_get_enum (struct ast_channel *chan, const char *number, char *dst, int dstlen, char *tech, int techlen, char *suffix, char *options, unsigned int record, struct enum_context **argcontext) | 
| Lookup entry in ENUM. | |
| int | ast_get_txt (struct ast_channel *chan, const char *number, char *txt, int txtlen, char *suffix) | 
| Lookup DNS TXT record (used by app TXTCIDnum) | |
| struct ast_module * | AST_MODULE_SELF_SYM (void) | 
| static int | blr_ebl (const char *cc, const char *suffix, char *separator, int sep_len, char *apex, int apex_len) | 
| Evaluate the I-ENUM branch as stored in an EBL record. | |
| static int | blr_txt (const char *cc, const char *suffix) | 
| Determine the branch location record as stored in a TXT record. | |
| static int | cclen (const char *number) | 
| Determine the length of a country code when given an E.164 string. | |
| static int | ebl_callback (void *context, unsigned char *answer, int len, unsigned char *fullanswer) | 
| Callback for EBL record lookup. | |
| static int | enum_callback (void *context, unsigned char *answer, int len, unsigned char *fullanswer) | 
| Callback from ENUM lookup function. | |
| static char * | format_numeric_domain (const char *number, const char *suffix) | 
| static int | load_module (void) | 
| static unsigned int | parse_ie (char *data, unsigned int maxdatalen, unsigned char *src, unsigned int srclen) | 
| Parse NAPTR record information elements. | |
| static int | parse_naptr (unsigned char *dst, int dstsize, char *tech, int techsize, unsigned char *answer, int len, unsigned char *naptrinput) | 
| Parse DNS NAPTR record used in ENUM —. | |
| static int | private_enum_init (int reload) | 
| Initialize the ENUM support subsystem. | |
| static int | reload_module (void) | 
| static int | txt_callback (void *context, unsigned char *answer, int len, unsigned char *fullanswer) | 
| Callback for TXT record lookup, /ol version. | |
| static int | unload_module (void) | 
| Variables | |
| static struct ast_module_info | __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_GLOBAL_SYMBOLS | AST_MODFLAG_LOAD_ORDER , .description = "ENUM Support" , .key = ASTERISK_GPL_KEY , .buildopt_sum = AST_BUILDOPT_SUM, .support_level = AST_MODULE_SUPPORT_CORE, .load = load_module, .unload = unload_module, .reload = reload_module, .load_pri = AST_MODPRI_CORE, .requires = "extconfig", } | 
| static const struct ast_module_info * | ast_module_info = &__mod_info | 
| static int | ebl_alg = ENUMLOOKUP_BLR_CC | 
| static ast_mutex_t | enumlock = AST_MUTEX_INIT_VALUE | 
| static char | ienum_branchlabel [32] = "i" | 
ENUM Support for Asterisk.
Implement a caching mechanism for multiple enum lookups
The service type selection needs to be redone.
Definition in file enum.c.
| 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.
| chan | Channel | 
| number | E164 number with or without the leading + | 
| location | Number returned (or SIP uri) | 
| maxloc | Max length | 
| technology | Technology (from url scheme in response) You can set it to get particular answer RR, if there are many techs in DNS response, example: "sip" If you need any record, then set it to "ALL" string | 
| maxtech | Max length | 
| suffix | Zone suffix (WARNING: No defaults here any more) | 
| options | Options 'c' - Count number of NAPTR RR number - Position of the requested RR in the answer list 'u' - Full URI return (does not strip URI scheme) 'i' - Infrastructure ENUM lookup 's' - ISN based lookup 'd' - Direct DNS query | 
| record | The position of required RR in the answer list | 
| argcontext | Argument for caching results into an enum_context pointer (NULL is used for not caching) | 
| 1 | if found | 
| 0 | if not found | 
| -1 | on hangup | 
Definition at line 649 of file enum.c.
References ast_autoservice_start(), ast_autoservice_stop(), ast_calloc, ast_copy_string(), ast_debug, ast_free, ast_log, ast_mutex_lock, ast_mutex_unlock, ast_search_dns(), ast_strlen_zero(), ast_tvdiff_ms(), ast_tvnow(), blr_ebl(), blr_txt(), cclen(), ebl_alg, enum_callback(), enumlock, ENUMLOOKUP_BLR_CC, ENUMLOOKUP_BLR_EBL, ENUMLOOKUP_BLR_TXT, ENUMLOOKUP_OPTIONS_COUNT, ENUMLOOKUP_OPTIONS_DIRECT, ENUMLOOKUP_OPTIONS_IENUM, ENUMLOOKUP_OPTIONS_ISN, errno, ienum_branchlabel, LOG_WARNING, enum_context::naptrinput, NULL, and options.
Referenced by enum_query_read(), and function_enum().
| 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)
Really has nothing to do with enum, but anyway... Actually, there is now an internet-draft which describes how callerID should be stored in ENUM domains: draft-ietf-enum-cnam-04.txt The algorithm implemented here will thus be obsolete soon.
| chan | Channel | 
| number | E164 number with or without the leading + | 
| txt | Text string (return value) | 
| maxtxt | Max length of "txt" | 
| suffix | Zone suffix | 
Definition at line 995 of file enum.c.
References ast_autoservice_start(), ast_autoservice_stop(), ast_copy_string(), ast_debug, ast_free, ast_search_dns(), errno, format_numeric_domain(), txt_context::txt, txt_callback(), and txt_context::txtlen.
Referenced by function_txtcidname().
| struct ast_module * AST_MODULE_SELF_SYM | ( | void | ) | 
| 
 | static | 
Evaluate the I-ENUM branch as stored in an EBL record.
Definition at line 330 of file enum.c.
References ebl_context::apex, ebl_context::apex_len, ast_copy_string(), ast_log, ast_mutex_lock, ast_mutex_unlock, ast_search_dns(), ast_verb, ebl_callback(), enumlock, ienum_branchlabel, LOG_WARNING, ebl_context::sep_len, ebl_context::separator, and T_EBL.
Referenced by ast_get_enum().
| 
 | static | 
Determine the branch location record as stored in a TXT record.
Definition at line 201 of file enum.c.
References ast_log, ast_mutex_lock, ast_mutex_unlock, ast_search_dns(), ast_verb, enumlock, ienum_branchlabel, LOG_WARNING, and txt_callback().
Referenced by ast_get_enum().
| 
 | static | 
Determine the length of a country code when given an E.164 string.
Definition at line 116 of file enum.c.
Referenced by ast_get_enum().
| 
 | static | 
Callback for EBL record lookup.
Definition at line 256 of file enum.c.
References answer(), ast_copy_string(), ast_log, c, len(), LOG_WARNING, and NULL.
Referenced by blr_ebl().
| 
 | static | 
Callback from ENUM lookup function.
Definition at line 616 of file enum.c.
References answer(), ast_log, ast_realloc, ast_strdup, ast_strlen_zero(), c, ENUMLOOKUP_OPTIONS_COUNT, len(), LOG_WARNING, NULL, and parse_naptr().
Referenced by ast_get_enum().
| 
 | static | 
Definition at line 955 of file enum.c.
References ast_malloc.
Referenced by ast_get_txt().
| 
 | static | 
Definition at line 1067 of file enum.c.
References AST_MODULE_LOAD_FAILURE, AST_MODULE_LOAD_SUCCESS, and private_enum_init().
| 
 | static | 
Parse NAPTR record information elements.
Definition at line 376 of file enum.c.
References ast_log, len(), and LOG_WARNING.
Referenced by parse_naptr().
| 
 | static | 
Parse DNS NAPTR record used in ENUM —.
Definition at line 397 of file enum.c.
References answer(), ARRAY_LEN, ast_copy_string(), ast_debug, ast_log, d, len(), LOG_WARNING, NULL, and parse_ie().
Referenced by enum_callback().
| 
 | static | 
Initialize the ENUM support subsystem.
Definition at line 1030 of file enum.c.
References ast_config_destroy(), ast_config_load2(), ast_copy_string(), ast_log, ast_mutex_lock, ast_mutex_unlock, ast_variable_retrieve(), CONFIG_FLAG_FILEUNCHANGED, CONFIG_STATUS_FILEINVALID, CONFIG_STATUS_FILEMISSING, CONFIG_STATUS_FILEUNCHANGED, ebl_alg, enumlock, ENUMLOOKUP_BLR_CC, ENUMLOOKUP_BLR_EBL, ENUMLOOKUP_BLR_TXT, ienum_branchlabel, LOG_WARNING, reload(), and string.
Referenced by load_module(), and reload_module().
| 
 | static | 
Definition at line 1077 of file enum.c.
References private_enum_init().
| 
 | static | 
Callback for TXT record lookup, /ol version.
Definition at line 151 of file enum.c.
References answer(), ast_copy_string(), ast_log, c, len(), LOG_WARNING, and NULL.
Referenced by ast_get_txt(), and blr_txt().
| 
 | static | 
| 
 | static | 
| 
 | static | 
| 
 | static | 
Definition at line 96 of file enum.c.
Referenced by ast_get_enum(), and private_enum_init().
| 
 | static | 
Definition at line 101 of file enum.c.
Referenced by ast_get_enum(), blr_ebl(), blr_txt(), and private_enum_init().
| 
 | static | 
Definition at line 91 of file enum.c.
Referenced by ast_get_enum(), blr_ebl(), blr_txt(), and private_enum_init().