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/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 | |
int | ast_enum_init (void) |
int | ast_enum_reload (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. More... | |
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) More... | |
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. More... | |
static int | blr_txt (const char *cc, const char *suffix) |
Determine the branch location record as stored in a TXT record. More... | |
static int | cclen (const char *number) |
Determine the length of a country code when given an E.164 string. More... | |
static int | ebl_callback (void *context, unsigned char *answer, int len, unsigned char *fullanswer) |
Callback for EBL record lookup. More... | |
static int | enum_callback (void *context, unsigned char *answer, int len, unsigned char *fullanswer) |
Callback from ENUM lookup function. More... | |
static unsigned int | parse_ie (char *data, unsigned int maxdatalen, unsigned char *src, unsigned int srclen) |
Parse NAPTR record information elements. More... | |
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 —. More... | |
static int | private_enum_init (int reload) |
Initialize the ENUM support subsystem. More... | |
static int | txt_callback (void *context, unsigned char *answer, int len, unsigned char *fullanswer) |
Callback for TXT record lookup, /ol version. More... | |
Variables | |
static int | ebl_alg = ENUMLOOKUP_BLR_CC |
static ast_mutex_t | enumlock = { PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP , NULL, 1 } |
static char | ienum_branchlabel [32] = "i" |
ENUM Support for Asterisk.
Implement a caching mechanism for multile enum lookups
The service type selection needs to be redone.
Definition in file enum.c.
#define ENUMLOOKUP_BLR_CC 0 |
Definition at line 87 of file enum.c.
Referenced by ast_get_enum(), and private_enum_init().
#define ENUMLOOKUP_BLR_EBL 2 |
Definition at line 89 of file enum.c.
Referenced by ast_get_enum(), and private_enum_init().
#define ENUMLOOKUP_BLR_TXT 1 |
Definition at line 88 of file enum.c.
Referenced by ast_get_enum(), and private_enum_init().
#define ENUMLOOKUP_OPTIONS_COUNT 1 |
Definition at line 590 of file enum.c.
Referenced by ast_get_enum(), and enum_callback().
#define ENUMLOOKUP_OPTIONS_DIRECT 8 |
Definition at line 596 of file enum.c.
Referenced by ast_get_enum().
#define ENUMLOOKUP_OPTIONS_IENUM 4 |
Definition at line 594 of file enum.c.
Referenced by ast_get_enum().
#define ENUMLOOKUP_OPTIONS_ISN 2 |
Definition at line 592 of file enum.c.
Referenced by ast_get_enum().
int ast_enum_init | ( | void | ) |
Definition at line 1006 of file enum.c.
References private_enum_init().
Referenced by main().
int ast_enum_reload | ( | void | ) |
Definition at line 1011 of file enum.c.
References private_enum_init().
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 632 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(), context, enum_context::count, enum_context::dst, enum_context::dstlen, 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, LOG_WARNING, enum_naptr_rr::naptr, enum_context::naptr_rrs, enum_context::naptr_rrs_count, enum_context::naptrinput, enum_context::options, naptr::order, enum_context::position, naptr::pref, enum_naptr_rr::result, enum_naptr_rr::sort_pos, enum_naptr_rr::tech, enum_context::tech, and enum_context::techlen.
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 927 of file enum.c.
References ast_autoservice_start(), ast_autoservice_stop(), ast_copy_string(), ast_debug, errno, and txt_context::txt.
Referenced by function_txtcidname().
|
static |
Evaluate the I-ENUM branch as stored in an EBL record.
Definition at line 324 of file enum.c.
References ebl_context::apex, ast_copy_string(), ast_log(), ast_mutex_lock, ast_mutex_unlock, ast_search_dns(), ast_verb, ebl_callback(), enumlock, LOG_WARNING, ebl_context::pos, 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 195 of file enum.c.
References ast_log(), ast_mutex_lock, ast_mutex_unlock, ast_search_dns(), ast_verb, enumlock, LOG_WARNING, txt_context::txt, 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 110 of file enum.c.
Referenced by ast_get_enum().
|
static |
Callback for EBL record lookup.
Definition at line 250 of file enum.c.
References ebl_context::apex, ebl_context::apex_len, ast_copy_string(), ast_log(), context, LOG_WARNING, ebl_context::pos, ebl_context::sep_len, and ebl_context::separator.
Referenced by blr_ebl().
|
static |
Callback from ENUM lookup function.
Definition at line 599 of file enum.c.
References ast_log(), ast_realloc, ast_strdup, ast_strlen_zero(), context, enum_context::count, enum_context::dst, enum_context::dstlen, ENUMLOOKUP_OPTIONS_COUNT, LOG_WARNING, enum_naptr_rr::naptr, enum_context::naptr_rrs, enum_context::naptr_rrs_count, enum_context::naptrinput, enum_context::options, parse_naptr(), enum_naptr_rr::result, enum_naptr_rr::sort_pos, enum_naptr_rr::tech, enum_context::tech, and enum_context::techlen.
Referenced by ast_get_enum().
|
static |
Parse NAPTR record information elements.
Definition at line 370 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 391 of file enum.c.
References ARRAY_LEN, ast_copy_string(), ast_debug, ast_log(), LOG_WARNING, and parse_ie().
Referenced by enum_callback().
|
static |
Initialize the ENUM support subsystem.
Definition at line 968 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, enumlock, ENUMLOOKUP_BLR_CC, ENUMLOOKUP_BLR_EBL, ENUMLOOKUP_BLR_TXT, EVENT_FLAG_SYSTEM, LOG_WARNING, manager_event, and string.
Referenced by ast_enum_init(), and ast_enum_reload().
|
static |
Callback for TXT record lookup, /ol version.
Definition at line 145 of file enum.c.
References ast_copy_string(), ast_log(), context, LOG_WARNING, txt_context::txt, and txt_context::txtlen.
Referenced by blr_txt().
|
static |
|
static |
Definition at line 95 of file enum.c.
Referenced by ast_get_enum(), blr_ebl(), blr_txt(), and private_enum_init().