Allow specifying a port number in the user portion of a register => line in sip.conf

With this commit, a register => line in sip.conf may contain a port number in the
"user" section of the line. Please see CHANGES and sip.conf.sample for more
details regarding this.

(closes issue #14198)
Reported by: Nick_Lewis
Patches:
      chan_sip.c-domainport2.patch uploaded by Nick (license 657)
Tested by: Nick_Lewis



git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@168575 65c4cc65-6c06-0410-ace0-fbb531ad65f3
1.6.2
Mark Michelson 17 years ago
parent ef6ad2b53c
commit 453b4cb8fb

@ -41,6 +41,9 @@ SIP Changes
option is required to interoperate with devices that have non-standard SDP
session version implementations (observed with Microsoft OCS). This option
is diabled by default.
* The parsing of register => lines in sip.conf has been modified to allow a port
to be present in the "user" portion. Please see the sip.conf.sample file for more
information
Skinny Changes
--------------

@ -6852,14 +6852,23 @@ static int sip_register(const char *value, int lineno)
ast_log(LOG_WARNING, "Format for registration is [transport://]user[:secret[:authuser]]@host[:port][/contact][~expiry] at line %d\n", lineno);
return -1;
}
/* split user[:secret[:authuser]] */
secret = strchr(username, ':');
if (secret) {
*secret++ = '\0';
authuser = strchr(secret, ':');
if (authuser)
*authuser++ = '\0';
/* split user[:secret[:authuser]] from the end to allow : character in user portion*/
authuser = strrchr(username, ':');
if (authuser) {
*authuser++ = '\0';
secret = strrchr(username, ':');
if (secret)
*secret++ = '\0';
else {
secret = authuser;
authuser = NULL;
}
}
if ((authuser) && (ast_strlen_zero(authuser)))
authuser = NULL;
if ((secret) && (ast_strlen_zero(secret)))
secret = NULL;
/* split host[:port][/contact] */
expire = strchr(hostname, '~');
@ -10475,6 +10484,7 @@ static int transmit_register(struct sip_registry *r, int sipmethod, const char *
struct sip_pvt *p;
int res;
char *fromdomain;
char *domainport = NULL;
/* exit if we are already in process with this registrar ?*/
if (r == NULL || ((auth == NULL) && (r->regstate == REG_STATE_REGSENT || r->regstate == REG_STATE_AUTHSENT))) {
@ -10622,10 +10632,23 @@ static int transmit_register(struct sip_registry *r, int sipmethod, const char *
/* Fromdomain is what we are registering to, regardless of actual
host name from SRV */
if (!ast_strlen_zero(p->fromdomain)) {
if (r->portno && r->portno != STANDARD_SIP_PORT)
snprintf(addr, sizeof(addr), "sip:%s:%d", p->fromdomain, r->portno);
else
snprintf(addr, sizeof(addr), "sip:%s", p->fromdomain);
domainport = strrchr(p->fromdomain, ':');
if (domainport) {
*domainport++ = '\0'; /* trim off domainport from p->fromdomain */
if (ast_strlen_zero(domainport))
domainport = NULL;
}
if (domainport) {
if (atoi(domainport) != STANDARD_SIP_PORT)
snprintf(addr, sizeof(addr), "sip:%s:%s", p->fromdomain, domainport);
else
snprintf(addr, sizeof(addr), "sip:%s", p->fromdomain);
} else {
if (r->portno && r->portno != STANDARD_SIP_PORT)
snprintf(addr, sizeof(addr), "sip:%s:%d", p->fromdomain, r->portno);
else
snprintf(addr, sizeof(addr), "sip:%s", p->fromdomain);
}
} else {
if (r->portno && r->portno != STANDARD_SIP_PORT)
snprintf(addr, sizeof(addr), "sip:%s:%d", r->hostname, r->portno);

@ -432,6 +432,14 @@ srvlookup=yes ; Enable DNS SRV lookups on outbound calls
; and more readable because you don't have to write the parameters in two places
; (note that the "port" is ignored - this is a bug that should be fixed).
;
; Beginning with Asterisk version 1.6.2, the "user" portion of the register line may
; contain a port number. Since the logical separator between a host and port number is a
; ':' character, and this character is already used to separate between the optional "secret"
; and "authuser" portions of the line, there is a bit of a hoop to jump through if you wish
; to use a port here. That is, you must explicitly provide a "secret" and "authuser" even if
; they are blank. See the third example below for an illustration.
;
;
; Examples:
;
;register => 1234:password@mysipprovider.com
@ -448,6 +456,11 @@ srvlookup=yes ; Enable DNS SRV lookups on outbound calls
; Tip 1: Avoid assigning hostname to a sip.conf section like [provider.com]
; Tip 2: Use separate inbound and outbound sections for SIP providers
; (instead of type=friend) if you have calls in both directions
;
;register => 3456@mydomain:5082::@mysipprovider.com
;
; Note that in this example, the optional authuser and secret portions have
; been left blank because we have specified a port in the user section
;registertimeout=20 ; retry registration calls every 20 seconds (default)
;registerattempts=10 ; Number of registration attempts before we give up

Loading…
Cancel
Save