Make sure register= line supports both port and expiry at the same time.
authorOlle Johansson <oej@edvina.net>
Thu, 29 Jan 2009 11:19:29 +0000 (11:19 +0000)
committerOlle Johansson <oej@edvina.net>
Thu, 29 Jan 2009 11:19:29 +0000 (11:19 +0000)
(closes issue #14185)
Reported by: Nick_Lewis
Patches:
      chan_sip.c-expiryrequest6.patch uploaded by Nick (license 657)
Tested by: Nick_Lewis

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@172234 65c4cc65-6c06-0410-ace0-fbb531ad65f3

channels/chan_sip.c

index 28cf8c7..bc6decf 100644 (file)
@@ -6880,7 +6880,6 @@ static int sip_register(const char *value, int lineno)
        enum sip_transport transport = SIP_TRANSPORT_UDP;
        char buf[256] = "";
        char *username = NULL;
-       char *port = NULL;
        char *hostname=NULL, *secret=NULL, *authuser=NULL, *expire=NULL;
        char *callback=NULL;
 
@@ -6889,6 +6888,16 @@ static int sip_register(const char *value, int lineno)
 
        ast_copy_string(buf, value, sizeof(buf));
 
+       /* split [/contact][~expiry] */
+       expire = strchr(buf, '~');
+       if (expire)
+               *expire++ = '\0';
+       callback = strchr(buf, '/');
+       if (callback)
+               *callback++ = '\0';
+       if (ast_strlen_zero(callback))
+               callback = "s";
+
        sip_parse_host(buf, lineno, &username, &portnum, &transport);
 
        /* First split around the last '@' then parse the two components. */
@@ -6917,25 +6926,6 @@ static int sip_register(const char *value, int lineno)
        if ((secret) && (ast_strlen_zero(secret)))
                secret = NULL;
 
-       /* split host[:port][/contact] */
-       expire = strchr(hostname, '~');
-       if (expire)
-               *expire++ = '\0';
-       callback = strchr(hostname, '/');
-       if (callback)
-               *callback++ = '\0';
-       if (ast_strlen_zero(callback))
-               callback = "s";
-       /* Separate host from port when checking for reserved characters
-        */
-       if ((port = strchr(hostname, ':'))) {
-               *port = '\0';
-       }
-       /* And then re-merge the host and port so they are stored correctly
-        */
-       if (port) {
-               *port = ':';
-       }
        if (!(reg = ast_calloc(1, sizeof(*reg)))) {
                ast_log(LOG_ERROR, "Out of memory. Can't allocate SIP registry entry\n");
                return -1;