From 34df12851997a5bdf0ac6bc81864297737a98260 Mon Sep 17 00:00:00 2001 From: Joshua Colp Date: Tue, 23 Jan 2007 03:15:04 +0000 Subject: [PATCH] Add SRV Lookup support on outbound calls to chan_iax2. It's listed in the RFC so we might want to support it and please don't hurt me Marko ... (issue #7812 reported by drorlb) git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@51560 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- CHANGES | 1 + channels/chan_iax2.c | 22 +++++++++++----------- configs/iax.conf.sample | 4 ++++ 3 files changed, 16 insertions(+), 11 deletions(-) diff --git a/CHANGES b/CHANGES index 51c88b2241..1630f587d5 100644 --- a/CHANGES +++ b/CHANGES @@ -64,6 +64,7 @@ Changes since Asterisk 1.4-beta was branched: * Added G729 passthrough support to chan_phone for Sigma Designs boards. * Added the parkedcalltransfers option to features.conf * Added 's' option to Page application. + * Added the srvlookup option to iax.conf SIP changes ----------- diff --git a/channels/chan_iax2.c b/channels/chan_iax2.c index 1ede22adef..5ca384280b 100644 --- a/channels/chan_iax2.c +++ b/channels/chan_iax2.c @@ -180,6 +180,8 @@ static unsigned int tos = 0; static int min_reg_expire; static int max_reg_expire; +static int srvlookup = 0; + static int timingfd = -1; /* Timing file descriptor */ static struct ast_netsock_list *netsock; @@ -2674,8 +2676,6 @@ struct create_addr_info { static int create_addr(const char *peername, struct sockaddr_in *sin, struct create_addr_info *cai) { - struct ast_hostent ahp; - struct hostent *hp; struct iax2_peer *peer; ast_clear_flag(cai, IAX_SENDANI | IAX_TRUNK); @@ -2685,18 +2685,14 @@ static int create_addr(const char *peername, struct sockaddr_in *sin, struct cre if (!(peer = find_peer(peername, 1))) { cai->found = 0; - - hp = ast_gethostbyname(peername, &ahp); - if (hp) { - memcpy(&sin->sin_addr, hp->h_addr, sizeof(sin->sin_addr)); - sin->sin_port = htons(IAX_DEFAULT_PORTNO); - /* use global iax prefs for unknown peer/user */ - ast_codec_pref_convert(&prefs, cai->prefs, sizeof(cai->prefs), 1); - return 0; - } else { + if (ast_get_ip_or_srv(sin, peername, srvlookup ? "_iax._udp" : NULL)) { ast_log(LOG_WARNING, "No such host: %s\n", peername); return -1; } + sin->sin_port = htons(IAX_DEFAULT_PORTNO); + /* use global iax prefs for unknown peer/user */ + ast_codec_pref_convert(&prefs, cai->prefs, sizeof(cai->prefs), 1); + return 0; } cai->found = 1; @@ -8968,6 +8964,8 @@ static int set_config(char *config_file, int reload) maxauthreq = 3; + srvlookup = 0; + v = ast_variable_browse(cfg, "general"); /* Seed initial tos value */ @@ -9171,6 +9169,8 @@ static int set_config(char *config_file, int reload) maxauthreq = 0; } else if (!strcasecmp(v->name, "adsi")) { adsi = ast_true(v->value); + } else if (!strcasecmp(v->name, "srvlookup")) { + srvlookup = ast_true(v->value); } /*else if (strcasecmp(v->name,"type")) */ /* ast_log(LOG_WARNING, "Ignoring %s\n", v->name); */ v = v->next; diff --git a/configs/iax.conf.sample b/configs/iax.conf.sample index 4d8663c2e7..89e485bfe5 100644 --- a/configs/iax.conf.sample +++ b/configs/iax.conf.sample @@ -51,6 +51,10 @@ ; ;adsi=no ; +; Perform an SRV lookup on outbound calls +; +;srvlookup=yes +; ; You may specify a default account for Call Detail Records in addition ; to specifying on a per-user basis ;