Merged revisions 281687 via svnmerge from
[asterisk/asterisk.git] / channels / sip / config_parser.c
index 988231f..0ab9ed7 100644 (file)
@@ -288,7 +288,7 @@ AST_TEST_DEFINE(sip_parse_register_line_test)
        switch (cmd) {
        case TEST_INIT:
                info->name = "sip_parse_register_line_test";
        switch (cmd) {
        case TEST_INIT:
                info->name = "sip_parse_register_line_test";
-               info->category = "channels/chan_sip/";
+               info->category = "/channels/chan_sip/";
                info->summary = "tests sip register line parsing";
                info->description =
                                                        "Tests parsing of various register line configurations. "
                info->summary = "tests sip register line parsing";
                info->description =
                                                        "Tests parsing of various register line configurations. "
@@ -661,16 +661,18 @@ int sip_parse_host(char *line, int lineno, char **hostname, int *portnum, enum s
        else
                line = *hostname;
 
        else
                line = *hostname;
 
-       if ((port = strrchr(line, ':'))) {
-               *port++ = '\0';
+       if (ast_sockaddr_split_hostport(line, hostname, &port, 0) == 0) {
+               ast_log(LOG_WARNING, "Cannot parse host '%s' on line %d of sip.conf.\n",
+                       line, lineno);
+               return -1;
+       }
 
 
+       if (port) {
                if (!sscanf(port, "%5u", portnum)) {
                        ast_log(LOG_NOTICE, "'%s' is not a valid port number on line %d of sip.conf. using default.\n", port, lineno);
                        port = NULL;
                }
                if (!sscanf(port, "%5u", portnum)) {
                        ast_log(LOG_NOTICE, "'%s' is not a valid port number on line %d of sip.conf. using default.\n", port, lineno);
                        port = NULL;
                }
-       }
-
-       if (!port) {
+       } else {
                if (*transport & SIP_TRANSPORT_TLS) {
                        *portnum = STANDARD_TLS_PORT;
                } else {
                if (*transport & SIP_TRANSPORT_TLS) {
                        *portnum = STANDARD_TLS_PORT;
                } else {
@@ -696,7 +698,7 @@ AST_TEST_DEFINE(sip_parse_host_line_test)
        switch (cmd) {
        case TEST_INIT:
                info->name = "sip_parse_host_line_test";
        switch (cmd) {
        case TEST_INIT:
                info->name = "sip_parse_host_line_test";
-               info->category = "channels/chan_sip/";
+               info->category = "/channels/chan_sip/";
                info->summary = "tests sip.conf host line parsing";
                info->description =
                                                        "Tests parsing of various host line configurations. "
                info->summary = "tests sip.conf host line parsing";
                info->description =
                                                        "Tests parsing of various host line configurations. "