aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormmichelson <mmichelson@f38db490-d61c-443f-a65b-d21fe96a405b>2009-02-09 17:11:05 +0000
committermmichelson <mmichelson@f38db490-d61c-443f-a65b-d21fe96a405b>2009-02-09 17:11:05 +0000
commitb10d3f551791b40d29f3315d7374e6714dcde98c (patch)
tree272eec37c2b7e1cf0d2e095721ad4e7c75fa13d4
parenteb56ebd34f384913011896b5c1ae30cbb7ab6815 (diff)
Don't do an SRV lookup if a port is specified
RFC 3263 says to do A record lookups on a hostname if a port has been specified, so that's what we're going to do. See section 4.2. (closes issue #14419) Reported by: klaus3000 Patches: patch_chan_sip_nosrvifport_1.4.23.txt uploaded by klaus3000 (license 65) git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.4@174282 f38db490-d61c-443f-a65b-d21fe96a405b
-rw-r--r--channels/chan_sip.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/channels/chan_sip.c b/channels/chan_sip.c
index 5c8d14983..655553693 100644
--- a/channels/chan_sip.c
+++ b/channels/chan_sip.c
@@ -2922,7 +2922,7 @@ static int create_addr(struct sip_pvt *dialog, const char *opeer, struct sockadd
struct ast_hostent ahp;
struct sip_peer *p;
char *port;
- int portno;
+ int portno = 0;
char host[MAXHOSTNAMELEN], *hostn;
char peer[256];
@@ -2957,8 +2957,10 @@ static int create_addr(struct sip_pvt *dialog, const char *opeer, struct sockadd
}
} else {
hostn = peer;
- portno = port ? atoi(port) : STANDARD_SIP_PORT;
- if (srvlookup) {
+ /* Section 4.2 of RFC 3263 specifies that if a port number is specified, then
+ * an A record lookup should be used instead of SRV.
+ */
+ if (!port && srvlookup) {
char service[MAXHOSTNAMELEN];
int tportno;
int ret;
@@ -2970,6 +2972,9 @@ static int create_addr(struct sip_pvt *dialog, const char *opeer, struct sockadd
portno = tportno;
}
}
+ if (!portno)
+ portno = port ? atoi(port) : STANDARD_SIP_PORT;
+
hp = ast_gethostbyname(hostn, &ahp);
if (!hp) {
ast_log(LOG_WARNING, "No such host: %s\n", peer);