summaryrefslogtreecommitdiff
path: root/channels
diff options
context:
space:
mode:
authorMark Michelson <mmichelson@digium.com>2009-01-13 21:18:13 +0000
committerMark Michelson <mmichelson@digium.com>2009-01-13 21:18:13 +0000
commit453b4cb8fbec96b4fa2aae10002ca982089eabd1 (patch)
treec818b3bd2c641eb07b20c36f161f14286b283b05 /channels
parentef6ad2b53cd60b14ef03d97f8cb393e2f245551f (diff)
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
Diffstat (limited to 'channels')
-rw-r--r--channels/chan_sip.c45
1 files changed, 34 insertions, 11 deletions
diff --git a/channels/chan_sip.c b/channels/chan_sip.c
index c2062d56f..0a066c7dc 100644
--- a/channels/chan_sip.c
+++ b/channels/chan_sip.c
@@ -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);